-1

I want to Get the location name from location table which is not equal to the id present in user location I have following two tables

1) Master Data

Empno| EmpName | UserLocation
123456| Sabeeh   | 654
325641| Arsalan  | 500

2) Locations

Loc_id| Location 
 654  | Tando Alam
 544  | Dakhni Oil Plant

I want an Sql Query For this Problem

1 Answers1

0

You can select all records from the master table whose Loc_id does not exists in the locations table with a NOT EXISTS condition and a correlated subquery :

SELECT m.*
FROM master m
WHERE NOT EXISTS (
    SELECT 1 FROM locations l WHERE l.Loc_id = m.UserLocation
)
GMB
  • 216,147
  • 25
  • 84
  • 135