多个列
UPDATE a, b SET a.title = b.title, a. category= b.category WHERE a.id = b.id
子查询
UPDATE shop s SET city_name = ( SELECT name FROM city WHERE id = s.city_id );
一个表的cout更新另一个表的字段
UPDATE shop a SET a.goods_count = ( SELECT b.counts FROM ( SELECT mid, count(*) counts FROM goods WHERE is_delete = 0 AND STATUS = 1 GROUP BY mid ) b WHERE a.mid = b.mid )
时间: 2024-10-07 05:29:51