问题
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