方法一:
select * fromuserswhereemailslike ' % b @ email.com % ';
方法二:
MySQL字符串函数find_in_set (;
slect * fromuserswherefind _ in _ set (aa @ email.com),emails );
这样就可以了。 怎么理解?
mysql中有许多字符串函数find_in_set(str1,str2),返回str2中str1所在位置的索引。 str2必须用“,”拆分。
注: str2为no1:「3、6、13、24、33、36”,no2:「13、33、36、39”时,判断两个数据中str2字段是否包含“3”
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
方法三:
使用locate(substr,str)函数,如果包括则返回0的整数,否则返回0
示例:确定site表的url是否包含' http://'子字符串,如果不包含,则在url字符串的开头update site set url =concat('http://',url) where locate('http://',url)=0
注意不要在mysql字符串拼接中使用加号,使用concat函数