Jump to content

Archived

This topic is now archived and is closed to further replies.

nabeel21

join two tables and return missing rows

Recommended Posts

Here are 2 tables which share the same columns (CITY and COUNTY)

 

TB1 (Main table that stores the info of all cities and counties)

 

CITY-------------------------COUNTY

---------------------------------------

Tampa----------------------Hillsborough

Orlando---------------------Orange

Frostproof-------------------Polk

Arcadia----------------------Desoto

County----------------------Collier

Tallahassee-----------------Leon

----------------------------------------------

 

TB2 (Contains info for all cities and counties who have submitted data)

 

CITY--------------------------COUNTY

---------------------------------------

Arcadia----------------------Desoto

County----------------------Collier

Tallahassee-----------------Leon

------------------------------------------------

 

Now I want to query TB1 and find out which city/county has NOT submitted their data.

 

The query should return

 

CITY-------------------------COUNTY

----------------------------------------

Tampa----------------------Hillsborough

Orlando---------------------Orange

Frostproof------------------Polk

 

 

Thanks in advance.

Share this post


Link to post
Share on other sites

SELECT TB1.city FROM TB1 LEFT JOIN TB2 ON TB1.city = TB2.city 

WHERE TB2.city IS NULL

 

hth

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.