Searching in mysql db with narrow results
My search query is something like this
SELECT files.id,files.file,files.name,files.uid,files.size,files.downloads,files.deleted,files.descr,
files.upload_id,files.thumb,files.category,files.expirydate,
MATCH(name,descr) AGAINST ('$all $none $any' In BOOLEAN MODE) AS score, users.`user`
FROM files Inner Join users ON files.uid = users.id
WHERE MATCH(name,descr) AGAINST ('$all $none $any' IN BOOLEAN MODE) AND files.deleted = 0 ORDER BY score DESC
In this $all $none $any
is the keywords inputed by user to search.
I want to narrow down the search results based on categories so how the query should be written for this.
I tried adding something like this after AND files.deleted = 0 AND category= 'Other'
this works fine but just incase if the users has selected two categories to search in this doesnt work, I use AND开发者_Go百科 category= 'Other' AND category = 'Images'
Thank You.
... files.deleted = 0 AND category IN('Other','Images')
精彩评论