Using an or in my join

W

webicky

Wondering if whether you can use an OR in a join. currently I have a
table (principal_data_export) with variable cdscode & altcdscode I
want the table to FIRST match via cdscode and then to altcdscode.

Can that be done?

This only gives me data where I match on CDS CODE but not altcdscode:

SELECT principal_data_export.cdscode,
principal_data_export.altcdscode, [Filtered Query with CDS1
created].cdscode1
FROM principal_data_export INNER JOIN ([Filtered Query with CDS1
created] INNER JOIN Ca2009entities_csv ON ([Filtered Query with CDS1
created].[County Code] = Ca2009entities_csv.[County Code]) AND
([Filtered Query with CDS1 created].[District Code] =
Ca2009entities_csv.[District Code]) AND ([Filtered Query with CDS1
created].[School Code] = Ca2009entities_csv.[School Code])) ON
principal_data_export.cdscode = [Filtered Query with CDS1
created].cdscode1;
 
J

Jeff Boyce

If one or the other condition must be true (i.e., match) then the OR covers
that.

If both conditions must be true (i.e., match), then use the AND.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
B

Ben Webman

That works.
SELECT principal_data_export.cdscode,
principal_data_export.altcdscode, [Filtered Query with CDS1
created].cdscode1
FROM principal_data_export INNER JOIN [Filtered Query with CDS1
created] ON principal_data_export.cdscode = [Filtered Query with CDS1
created].cdscode1 OR principal_data_export.altcdscode = [Filtered
Query with CDS1 created].cdscode1;


If one or the other condition must be true (i.e., match) then the OR covers
that.

If both conditions must be true (i.e., match), then use the AND.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Wondering if whether you can use an OR in a join.  currently I have a
table (principal_data_export) with variable cdscode & altcdscode  I
want the table to FIRST match via cdscode and then to altcdscode.
Can that be done?
This only gives me data where I match on CDS CODE but not altcdscode:
SELECT principal_data_export.cdscode,
principal_data_export.altcdscode, [Filtered Query with CDS1
created].cdscode1
FROM principal_data_export INNER JOIN ([Filtered Query with CDS1
created] INNER JOIN Ca2009entities_csv ON ([Filtered Query with CDS1
created].[County Code] = Ca2009entities_csv.[County Code]) AND
([Filtered Query with CDS1 created].[District Code] =
Ca2009entities_csv.[District Code]) AND ([Filtered Query with CDS1
created].[School Code] = Ca2009entities_csv.[School Code])) ON
principal_data_export.cdscode = [Filtered Query with CDS1
created].cdscode1;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top