mysql 常用技巧

时间:2023-12-04 23:42:56

1.正则使用 比 LIKE 会牺牲很多的系统资源 尽量不要用

  正则的语法和JS PHP 差不多

  select * from t1 where email REGEXP "@163[,.]com$";

  select * from t1 where email like "%@163.com" or email like "%@163,com"

2.REPLACE 函数的使用

  UPDATE `v9_zhushou` SET `thumb` = REPLACE(`thumb`, 'http://localhost/ciwei/', 'http://www.qciwei.com/ciwei/') WHERE `id` > 0

  UPDATE `v9_zhushou_data` SET `iphone` = REPLACE(`iphone`, 'http://localhost/ciwei/', 'http://www.qciwei.com/ciwei/') WHERE `id` = 300