sql - Having issues using a Right Join in MS Access 2010 with two tables that have the same fields -
i have 2 tables, table , table b. each table have 4 fields, name of fields same both. both tables extracted other tables, , each record acts primary key.
i want write query in ms access 2010 gets data unique table b , not shared table a. using following image reference, , looks need right join.
hello. there not right sql, i've tested , getting incorrect result. below closest i've gotten:
select distinct tableb.* tableb right join tablea on (tableb.field1 = tablea.field1) , (tableb.field2 = tablea.field2) , (tableb.field3 = tablea.field3) , (tableb.field4 = tablea.field4) (((tablea.field1) null));
i think clearer use not exists:
select tableb.* tableb not exists (select 1 tablea (tableb.field1 = tablea.field1) , (tableb.field2 = tablea.field2) , (tableb.field3 = tablea.field3) , (tableb.field4 = tablea.field4) ); your use of right join incorrect. phrased, want left join. is, want keep rows in first table (the "left" table in join) regardless of whether or not match exists in second table. however, not exists same thing , logic bit clearer.

Comments
Post a Comment