MySQL Fulltext search where category = something
This is driving me crazy, I have searched everywhere and can not seem to find an example. I am doing a fulltext MySQL search like so:
SELECT *
FROM `posts`
WHERE MATCH (
`title` , `description` , `location`
)
AGAINST (
'SEARCH TERM'
IN BOOLEAN
MODE
)
ORDER BY `id` DESC
LIMIT 0 , 100
that works fine but I have another column in my table "category" and would like to return results only from that category something like:
SELECT * FROM `posts` WHERE MATCH ( `title` , `description` , `location` 开发者_JAVA技巧) AGAINST ( 'fayetteville' IN BOOLEAN MODE ) WHERE `category` = 'SEARCH CATEGORY' ORDER BY `id` DESC LIMIT 0 , 100of course that second bit of code does not work, but how can I do this in MySQL?
Thanks
You can only have one WHERE clause. Change your second WHERE to AND.
SELECT *
FROM `posts`
WHERE MATCH ( `title` , `description` , `location` )
AGAINST ( 'fayetteville' IN BOOLEAN MODE )
AND `category` = 'SEARCH CATEGORY'
ORDER BY `id`
DESC LIMIT 0 , 100
精彩评论