当前位置:主页 > 数据库 > Mysql >

mysql的sql语句特殊处理语句总结(必看)

时间:2021-09-05 09:45:43 | 栏目:Mysql | 点击:

1、更新整张表,如果某一行数据的某一列的值为空,那么让他和另一列字段的值相等

UPDATE ot_tgbz set update_day=if(update_day is null,date,update_day);


2、更新整张表,如果某个字段大于2,那么把他们都更新成2;

UPDATE ot_user set xingyun_num=if(xingyun_num > 2,2,xingyun_num);


3、把shop_goods这个表里的thumb字段里的内容中含有https://www.jb51.net/的网址全部替换成空的。

update shop_goods  set thumb= replace (thumb,'https://www.jb51.net/','') where thumb like '%https://www.jb51.net/%';


4、sql语句多字段where查询

$map= " CAST(
  `UE_account` AS CHAR CHARACTER
     SET utf8
  ) LIKE '%$data%'
  OR CAST(
    `UE_accName` AS CHAR CHARACTER
    SET utf8
  ) LIKE '%$data%'
  OR CAST(
    `UE_truename` AS CHAR CHARACTER
    SET utf8
  ) LIKE '%$data%'
  OR CAST(
    `UE_phone` AS CHAR CHARACTER
    SET utf8
  ) LIKE '%$data%'";

您可能感兴趣的文章:

相关文章