blocnt blocnt - 2 years ago 69
MySQL Question

mysql - Use two "%" in LIKE clause

I want to use something like

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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download