php - mysql OR clause respective to AND clause -
i have form filtering/sorting database records.
i'm filtering posts author, category, , tags. i'm using and
clause author , category , or
clause tags (multiple tags can entered)
a query looks this
select * (`posts`) `author` = 'dan' , `category` = 'technology' , `tags` '%ebook%' or `tags` '%ipad%' or `tags` '%apple%'
the query above returns posts contain tag searched regardless of author or category.
i want return posts containing tags ebook, ipad, apple
within author name dan
, category technology
.
how possible in mysql?
add brackets around or's
select * (`posts`) `author` = 'dan' , `category` = 'technology' , ( `tags` '%ebook%' or `tags` '%ipad%' or `tags` '%apple%' )
Comments
Post a Comment