sqlite 不支持 right join和full join

SQLite

只支持 left join

不支持 right join 和 full join

sqlite 执行 full outer join 、right join 报错:RIGHT and FULL OUTER JOINs are not currently supported。

 

解决方法:

利用 sqlite 支持左连接 left join ,

全量显示AA表中的内容:

select *

from AA a

left join BB b

on a.id = b.id

 

实现右外连接:把AA BB位置换一下

全量显示BB表中的内容:

select *

from BB b

left join AA a

on b.id=a.id

 

实现全外链接:使用union连接两个left join

两张表全量显示:

select * from AA a  left  join BB b on a.id=b.id

union

select * from BB b left join AA a on b.id=a.id

 

*****

join分为 内联(inner join)+ 外联(outer join)

inner join = join 使用最多

outer join是个范围,包含 left outer join , roght outer join , full outer join

join 必须 搭配 on 一起使用,所有的 join结果是笛卡尔积 a x b,但是on是筛选条件,基于on去找匹配的条目,再根据 inner/outer 选择是否添加某张表的全部行内容。

*****

 

posted @ 2022-01-19 16:09  Widereye  阅读(743)  评论(0编辑  收藏  举报