转载地址:http://blog.sina.com.cn/s/blog_71e2015f01017pnl.html
使用locate(substr,str)函数,如果包含,返回>0的数,否则返回0
例子:判断site表中的url是否包含'http://'子串,如果不包含则拼接在url字符串开头
update site set url =concat('http://',url) where locate('http://',url)=0
注意mysql中字符串的拼接不能使用加号+,用concat函数
本文介绍了MySQL中如何使用locate()函数来判断一个字符串是否包含指定的子串,并通过concat()函数实现字符串拼接,避免使用加号进行拼接。
729

被折叠的 条评论
为什么被折叠?



