Compare two Tables using Left Join

10 Feb

Ref:http://www.todoexpertos.com/categorias/ciencias-e-ingenieria/respuestas/444652/comparar-dos-tablas

1) All records from  Table 1 that Not Exist in Table 2
SELECT Table1.Codigo, Table2.Codigo
FROM Table1 LEFT JOIN Table2 ON Table1.Codigo = Table2.Codigo
WHERE (((Table1.Linea) Is Null));

2) All records from t Table 2 that not exist in Table 1 (invert columns from prevoius example)

My Example Reference:

SELECT A.GMAID, A.GMOBJ, A.GMSUB,A.GMMCU, A.GMDL01
FROM f0901_obj as A LEFT JOIN f0902_obj as B ON A.gmAID = B.gbAID
WHERE (((B.gbAID) Is Null)) order by a.gmobj;

–evick

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: