MySQL selects using wildcards (but a wildcard in a field)

I have a mysql 5 table with a char field containing

DOG DOUG CAT MOUSE 

Now I want to SELECT in this field, finding any rows in which this field exists in the row, for example "DOGGY". (This is the opposite of how you usually use a wildcard). So I want to choose something like: CHOOSE FROM THE TABLE WHICH FIELD IS A DOG

Is it possible?

+6
source share
2 answers
 select * from mytable where 'doggy' like concat('%',mycol,'%') 
+14
source

You can use LOCATE() to achieve this:

 SELECT * FROM MyTable WHERE LOCATE(MyField, 'DOGGY') != 0; 
+5
source

Source: https://habr.com/ru/post/909915/


All Articles