How to write a MS SQL query to filter data from 2 tables

Hello All,
I am new to SQL and trying to write a select query to get a result from 2 table. Table1 is CONTACTS and 2 is USERS. CONTACTS has a field named Assigned_user_ID, which should have the same value as field ID in USERS. We actually migrated from one system to this new system, due which we have records in CONTACTS with Assigned_user_id, which are not in USERS ID. These
I want to get a list of those records which do not match in both tables. I have come up with this code, which doesn't give me any results. However, it doesn't give me any error either. Please see the code.
Many Thanks

select * from contacts 
inner join users on contacts.assigned_user_id =  
where contacts.assigned_user_id !=

Open in new window

Who is Participating?
LimbeckConnect With a Mentor Commented:
select * from contacts
where not exists (select 1 from  users where contacts.assigned_user_id =  )
select * from contacts
left join users on contacts.assigned_user_id =  
where id is null
select * from contacts c
where c.assigned_user_id  not in  (select from  users u where c.assigned_user_id =  )
Rafi001Author Commented:
Thanks Limbeck, the query worked brilliantly.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.