简体   繁体   中英

Access SQL Full Outer Join

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

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;

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM