1

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

qing zhangqing
  • 381
  • 1
  • 4
  • 13

3 Answers3

1

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;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Hi Gordon, It works on Oracle. But I am not sure why I can not run it on access sql. but thank you at lease I have one solution – qing zhangqing Mar 02 '18 at 18:50
  • 2
    Oracle SQL differs from MS Access SQL differs from MySQL SQL differs from et cetera... – Rene Mar 02 '18 at 22:17
1

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

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

Screenshot

Below you can see the result of an SQL statement similar to the one above. Both tables are joined using Table1.joinColumn = Table2.joinColumn

  • A and B are only in T1
  • C and D are in both tables T1 and T2
  • E, F, and G are only in T2

Access_Result_Left_Join_Union_Right_Join

surfmuggle
  • 5,527
  • 7
  • 48
  • 77
tysonwright
  • 1,525
  • 1
  • 9
  • 19
0

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

EllieK
  • 259
  • 4
  • 14