views:

91

answers:

1

I would like to use something like the following:

SELECT city FROM cities WHERE city LIKE %D% AND country_id = '12'
+6  A: 

You need to quote the string

SELECT city FROM cities WHERE city LIKE '%D%' AND country_id = '12'

But remember that using a LIKE with a pattern starting with a "%" means the server will NOT use an index on 'city' column - it may not matter in your specific case but something to be aware of. Here's the reference since your comment indicates you're not familiar with indexes.

DVK
What do you men it will not use an index on the city column? what problems could the have?
Josh K
@Josh K: It could be slow.
Felix Kling
@Josh - I added the link to the documentation which explains that.
DVK