mysql 实用语句

1 根据两个表中相同的字段数据 去更新其中一张表的另一个字段。

update A , B set A.编码=B.编码 where A.地市=B.地市
  
2 根据同表中相同的字段数据 去更新表的另一个字段。

update A a ,A b set a.sj=b.sj+1 WHERE  a.id=b.id and a.id>8
3 冒泡排序
select a.* from z_timetest a where 2 > (select count(*) from z_timetest where yg_id = a.yg_id and sj > a.sj )
原文地址:https://www.cnblogs.com/xjt360/p/4186101.html