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.

enter image description here

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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -