I have a mysql 5 table with a char field holding
DOG
DOUG
CAT
MOUSE
Now I want to SELECT on this field, finding any rows where that field exist within a string, like "DOGGY". (This is opposite of how you normally use a wildcard). So I want a select something like: SELECT FROM TABLE WHERE FIELD IS SUBSTRING OF "DOGGY"
Is this possible?
select * from mytable where 'doggy' like concat('%',mycol,'%')
You should be able to use LOCATE()
to achieve this:
SELECT * FROM MyTable WHERE LOCATE(MyField, 'DOGGY') != 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With