Search code examples
mysqlsqldql

How can I use two where clauses in a SQL query


So I'm learning SQL and trying to make a query with two 'where' clauses, one of them is just a simple WHERE status='error', and in addition I need to a add a second 'WHERE' but using also 'LIKE', my Query looks something like this:

SELECT sync.id
WHERE status='ERROR'
WHERE search LIKE '%sometext%'

But what I've been reading is that is not possible to do that, how can I use the two statements since both are required?


Solution

  • Try like this way by using AND to make both conditions are required on the SELECT.

    N.B: You missed the FROM clause

    SELECT sync.id FROM table_name_goes_here
    WHERE status='ERROR' AND
    search LIKE '%sometext%'