Inner Join needed?

bde7503

New Member
Joined
Dec 12, 2013
Messages
37
I am trying to return all records where the sid field doesn't match - this is just a test and there is just one record between the 2 tables where the sid doesn't match but i get no results returned.
I have to use an inner join to get the records returned for both tables correct?
Not sure why it wont return the 2 records so i can see the difference between the sids.
Any help is appreciated!

SELECT table1.fn,table1.sid,table1.loc,table2.fn,table2.sid,table2.loc
FROM table1 inner JOIN table2
ON table1.sid=table2.sid
where table2.sid is null
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
6,140
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Try changing the inner join to a left join.
 

bde7503

New Member
Joined
Dec 12, 2013
Messages
37
thanks, that works - is there any way to get it to return all the values? I know a left join will return all the records from table1 and of course it leaves the non matching from table 2 blank - I'd like to see them all, or does that simply require 2 separate queries?
 

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
6,140
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Run a left join query, then run a right join query. And finally, run a union query joining the first two queries.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,939
Messages
5,621,716
Members
415,853
Latest member
Newlife72

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top