Using an or in my join

  • Thread starter Thread starter webicky
  • Start date Start date
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;
 
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
 
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;
 
Back
Top