MySQL高级--sql语句

  1. sql执行顺序

sql语句表连接查询(join)

    • 等值连接:select  * from a inner join b on a.id=b.id;

    • 左连接:select * from a left join b on a.id=b.id;
    • 右连接:select * from a right join b on a.id=b.id;

    • 左连接(变形):select * from a left join b on a.id=b.id where b.id is NULL;
      •  
    • 有连接(变形):select * from a right join b on a.id=b.id where a.id is NULL; 

    • 全连接:select * from a FULL OUTER JOIN b on a.id = b.id;
      • mysql语句:select * from a left join b where a.id=b.id  union   select * from a right join b where a.id = b.id;

      •     
    • 全连接(变形):select * from a FULL OUTER JOIN b on a.id= b.if where a.id is NULL or b.id is NULL;
      • mysql语句:select * from a left join b on a.id= b.id where b.id is null   union  select * from a right join b on a.id= b.id where a.id is null;
      •  

         

 

posted @ 2021-05-13 16:39  张紫韩  阅读(71)  评论(0编辑  收藏  举报