Method one: like
SELECT * FROM table WHERE field names like "% character%";
Method two: find_in_set ()
Mysql string functions using FIND_IN_SET ();
SELECT * FROM users WHERE find_in_set ( 'character', field name);
MySQL string function There are many FIND_IN_SET (str1, str2) function returns the index position is located in str2 str1, str2 must "," separated.
NOTE: When str2 is NO1: "3,6,13,24,33,36", NO2: "13,33,36,39", it is determined whether the two data fields contain str2 '3', the function can be perfect solution
mysql > SELECT find_in_set('3','3,6,13,24,33,36') as test;
-> 1
MySQL> FIND_IN_SET the SELECT ( '. 3', '13,33,36,39') AS Test;
-> 0
Note: When large amount of data is relatively large performance cost function
Method three: locate (character, field names)
Use locate (character, field names) function, if included, returns> number 0, otherwise returns 0,
It is a position in an alias
select * from table where locate (character field)
select * from table where position (character in the field);
Examples: determining whether the site table comprising url 'http: //' substring, if the splice is not included at the beginning of the url string
update site set url = concat ( ' http: //', url) where locate ( 'http : // ', url) = 0
Note that the stitching is not mysql string plus sign +, with concat function
Method four: INSTR (field, characters)
select * from table where INSTR (field character)
Original link: https://blog.csdn.net/lchq1995/article/details/86615258