Access SQL Full Outer Join

喜你入骨 提交于 2021-02-11 18:21:56

问题


Hi I was trying to Full Outer join two tables on access because I want to keep all items.

here is my code:

    SELECT aa.*, bb.firstname, bb.lastname, bb.totalcost
    FROM (select IT.*,HR.*from IT
    left join HR on HR.firstname=it.firstname and HR.lastname=IT.lastname)  
    AS 
    aa FULL OUTER JOIN 2016totalcost AS bb ON (bb.lastname=aa.IT.lastname) 
    AND (bb.firstname=aa.IT.firstname);

But I got error syntax error in from clause

Thanks for help


回答1:


Access does not recognize a Full Outer Join.

Here is an example of how to write the equivalent for MSA.

How do I write a full outer join query in access




回答2:


Do a LEFT JOIN and UNION it to a RIGHT Join:

SELECT 
    *
FROM 
    Table1
LEFT JOIN 
    Table 2
ON 
    Table1.joincolumn = Table2.joincolumn
UNION
SELECT 
    *
FROM 
    Table1
RIGHT JOIN 
    Table 2
ON 
    Table1.joincolumn = Table2.joincolumn



回答3:


NOTE: The question was tagged Oracle when I answered.

The Oracle syntax would be:

select IT.*, HR.*, bb.firstname, bb.lastname, bb.totalcost
from IT left join
     HR
     on HR.firstname = it.firstname and HR.lastname = IT.lastname full outer join 
     2016totalcost tc 
     on tc.lastname = it.lastname and tc.firstname = it.firstname;


来源:https://stackoverflow.com/questions/49075392/access-sql-full-outer-join

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