php - How can I assign one part of the WHERE clause to multiple other parts of it? -
i make mysql query like: select * title '%".$_post["search"]."%' or '%".$_post["search"]."%' , costs < '".$max."'
this give me results title search , results search , costs smaller $max. want costs < $max title $search. dont want put costs < $max 2 times script. there way assign both? maybe brackets: where (title '%".$_post["search"]."%' or '%".$_post["search"]."%') , costs < '".$max."'
how can achieve this?
thank you! phpheini
yes, can use parentheses or evaluated first:
where (title '%foo%' or '%foo%') , costs < '20'
other remarks:
- i'd suggest escape strings using
mysql_string_real_escape
prevent sql injection attacks. or take @ pdo , prepared statements. - you may want @ full-text search alternative approach faster.
Comments
Post a Comment