开发者

Error in large MySql Query

I am trying to use the following MySql query, however it returns a syntax error at 'WHERE FIND_IN_SET('query', Alternate_name)' at line 3. I've tried googling it and looking through the MySql manual, however I can't seem to find how to fix it.

Query:

SELECT name, 'Events' as source FROM feed_events WHERE name LIKE '".$query."%' UNION ALL    
SELECT name, 'Venues' as source FROM feed_venues WHERE name LIKE '".$query."%' UNION ALL
SELECT name, 'Locations' as source FROM feed_locations WHERE name LIKE '".$query."%' OR WHERE FIND_IN_SET(开发者_StackOverflow中文版'".$query."', Alternate_name)

In the select statement which is having the problem, I am trying to select the names of cities that best fit the string the user has inputted ($query). In the first column is the city name and in the second column I have a comma separated list of alternative names for that city. The find_in_set() is supposed to search the items in that column to find a best match. Is there a way to fix this syntax error, or is find_in_set() not the ideal choice for what I am trying to do?


You don't need the second WHERE keyword. You can have 2 things in an OR like this

WHERE expression1 OR expression2

for instance:

WHERE field = '1' OR field = '2'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜