Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with query looking at two tables

Status
Not open for further replies.

DougP

MIS
Joined
Dec 13, 1999
Messages
5,985
Location
US
I would like to show all the matches between [Raw Data All].School and Projects.Company but also show any that don't match. like so
Company School
ABC ABC
DEF
GHI GHI
XYZ ZYZ
TUV

So we did projects for ABC, GHI, XYZ
but not for DEF and TUV, But I would like to see all of them as shown in my example. I would like to see DEF and TUV and have an empty space in the School column.
Is this possible?


SELECT Projects.Company, Projects.[Project Number], Projects.[Project Name], Projects.Facility
FROM [Raw Data All] INNER JOIN Projects ON [Raw Data All].School = Projects.Facility
WHERE (((Projects.Company) Like "the school*") AND ((Projects.[Project Number]) Like "97*") AND ((Projects.[Project Name]) Like "*Triennial*"));


TIA

DougP
 

SELECT Projects.Company, Projects.[Project Number], Projects.[Project Name], Projects.Facility
FROM [Raw Data All] left JOIN Projects ON [Raw Data All].School = Projects.Facility
WHERE (((Projects.Company) Like "the school*") AND ((Projects.[Project Number]) Like "97*") AND ((Projects.[Project Name]) Like "*Triennial*"));
 
It is worth reading:


Try:

Code:
SELECT Projects.Company, Projects.[Project Number], Projects.[Project Name], Projects.Facility
FROM Projects LEFT JOIN [Raw Data All] 
ON Projects.Facility=[Raw Data All].School
WHERE (((Projects.Company) Like "the school*") 
AND ((Projects.[Project Number]) Like "97*") 
AND ((Projects.[Project Name]) Like "*Triennial*"));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top