Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use two where clauses in a SQL query

Tags:

sql

mysql

dql

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?

like image 460
Daniela Cortes Avatar asked Dec 17 '25 18:12

Daniela Cortes


1 Answers

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%'
like image 182
Always Sunny Avatar answered Dec 19 '25 08:12

Always Sunny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!