problem with nested inner joins in SQLIte

强颜欢笑 提交于 2019-12-24 01:28:03

问题


The sql statement below will not run in SQLite:

select * 
from A
left join (B inner join C on B.fkC = C.pk) on A.optionalfkB = B.pk

I get a sqlException "unknown column B.pk"

According to the documentation @ http://www.sqlite.org/lang_select.html this should work, and it will work in all other sql implementations. Am I doing something wrong?


回答1:


It doesn't work because the "outer" query doesn't know what B is.

select * 
from A
left join (B inner join C on B.fkC = C.pk) B on A.optionalfkB = B.pk

The (B inner join C on B.fkC = C.pk) is weird without any select, but the specification does say that it is valid.



来源:https://stackoverflow.com/questions/7071283/problem-with-nested-inner-joins-in-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!