Delete Rows From Database

Hello,
I have two tables (Employees and Records) that both contain a FirstName and LastName column.  I want to create a Delete Query that will delete every row in the Employee's table where a data row's FirstName and LastName is not found in the Records table.
Gunit2507Asked:
Who is Participating?
 
anyoneisConnect With a Mentor Commented:
Just a minor addition: it is possible that simply concatenating first and last names could result in a false match. To ensure this doesn't happen, connect the two wih a delimiter, as in:

delete from employees where firstname + '|' + lastname not in
(select firstname + '|' + lastname from records).


David

0
 
spprivateCommented:
delete from employees where firstname+lastname not in
(select firstname+lastname from records).
But I would say this is a bad design and rather I would have Emp ID as a key in the child table and delete by the id.
0
 
Gunit2507Author Commented:
The other database doesn't have an employee ID or any value like that... So how would that look in SQL?
0
 
spprivateCommented:
you can use the same query as i mentioned earlier
0
All Courses

From novice to tech pro — start learning today.