7种SQL JOIN 关系 - 图1

    image.png

    1. # 内连接
    2. select <select_list> from table_a a inner join table_b b on a.key=b.key;

    image.png

    select <select_list> from table_a a right join table_b b on a.key=b.key;
    

    image.png

    select <select_list> from table_a a left join table_b b on a.key=b.key;
    

    image.png

    select <select_list> from table_a a left join table_b b on a.key=b.key where b.key is null;
    

    image.png

    select <select_list> from table_a a right join table_b b on a.key=b.key where a.key is null;
    

    image.png

    # 全连接
    select <select_list> from table_a a full outer join table_b b on a.key=b.key
    

    image.png

    select <select_list> from table_a a full outer join table_b b on a.key=b.key where a.key is null and b.key is null;