Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where OR where mysql - mysql query with two where clauses

Tags:

sql

php

mysql

I've got an SQL statement:

$sql =" SELECT DISTINCT
            scr.*  
        FROM scr 
            LEFT JOIN `users` ON `users`.user_id=scr.user_id

        WHERE $email_filter LOWER(scr.genre) LIKE '%$search_word_fix%' **HERE** $psez protage $wwc $prevoption $locatio  $rats $rat1 $rat2 $rat3 $rat4          
        GROUP by scr.sp_name  
        ORDER BY scr.grade DESC";

when I add lower(scr.classification) like '%$search_word_fix%' in "HERE" it doesn't display the correct results. I was thinking something like (where scr.genre = "searchkeyword" and other filters here) OR (where scr.classification ="searchkeyword" and other filters here)

like image 843
cppit Avatar asked Jan 19 '26 22:01

cppit


1 Answers

Only specify Where once. Additional clauses are specified just with "or" and "and"

Use parans to group order of operations

where (scr.genre = "searchkeyword" and other filters here) 
OR (scr.classification ="searchkeyword" and other filters here)
like image 69
atxdba Avatar answered Jan 22 '26 12:01

atxdba



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!