blocnt blocnt - 4 months ago 7
MySQL Question

mysql - Use two "%" in LIKE clause

I want to use something like

SELECT *
FROM blabla
WHERE date LIKE '2014%'
AND name = 'Jo%'
AND (( price > 0
OR time > 10));


But it doesn't return results because of

name = 'Jo%'


(but I know that there are results). I've tried 'Jo*' but it doesn't work.
It seems that only let one "%", right after LIKE clause.

How can I fix this?

Answer

You would use date LIKE '2014%' AND name LIKE 'Jo%', because the equals sign does not perform that pattern matching.