mysql更新字段部分内容,连接条件过滤

table 表(条件type=0)的字段 field_name 中 “old” 更改为 "new"
update table set field_name=replace(field_name,'old','new') where type=0;

将(条件id>100的)type为1176 更新为type 为1172;
UPDATE table_name SET type=1172 WHERE type=1176 and id>100;

联合表一 表二,筛选等级大于自己等级+18的用户
SELECT u.user_id ,u.cur_level , COUNT(t.user_id) AS us ,u.create_time FROM table1 AS u LEFT JOIN table2 AS t on u.user_id =t.user_id GROUP BY u.user_id HAVING us>(u.cur_level+18);

posted @ 2020-08-04 15:04  mlj0503  阅读(252)  评论(0编辑  收藏  举报