Method One:
SELECT * from the users WHERE emails like "%[email protected]%";
Method Two:
Use the MySQL string function find_in_set ();
SELECT * from Users WHERE find_in_set (' [email protected] ', emails);
This is possible, how to understand it?
MySQL has a lot of string functions Find_in_set (STR1,STR2) function is the return str2 in the location of the index STR1, str2 must be "," split open.
Note: When STR2 is NO1: "3,6,13,24,33,36", NO2: "13,33,36,39", determine whether the str2 field in two data contains ' 3 ', the function can be perfectly solved
MySQL > SELECT find_in_set (' 3 ', ' 3,6,13,24,33,36 ') as test;
1
MySQL > SELECT find_in_set (' 3 ', ' 13,33,36,39 ') as test;
0
Method Three:
Use the locate (SUBSTR,STR) function, if included, returns the number of >0, otherwise returns 0
Example: Determine if the URL in the site table contains the ' http://' substring, and if it is not included, stitch at the beginning of the URL string
Update site set URL =concat ('/http ', URL) where locate ('/HTTP ', URL) =0
Note that the concatenation of strings in MySQL cannot use the Plus +, with the concat function
MySQL string field 3 ways to determine if a string is included