常用sql浅谈

   1.在不同表,查询相同字段,通常用union all 连接,  select a,b,c from t_a  union all select a,b,c from t_b

   2.mysql中使用exists语法的时候,子查询中的id需要与外面查询的id相关联: 

      update  t_a a  set status = 1 where (select b.id  from t_b b where b.id = a. id);

猜你喜欢

转载自blog.csdn.net/z654893465/article/details/80053727