SQL delete procedure

I have a table that I am trying to clean up using a delete procedure.
Table name is TR
Columns are TR_ID,EmployeeID,TrainingID
I need to delete the row where the employee has a record with TrainingID = 171 ONLY if the employee has a record with a TrainingID = 113

Any help would be appreciated.
LVL 6
AkAlanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BurniePConnect With a Mentor Commented:
Sorry, forgot a part :

DELETE FROM TR WHERE TrainingID = 171 AND (SELECT COUNT(*) FROM TR TR2 WHERE TR2.TR_EmployeeID = TR.EmployeeID AND TrainingID = 113) > 0
0
 
BurniePCommented:
DELETE FROM TR WHERE TrainingID = 171 AND (SELECT COUNT(*) FROM TR TR2 WHERE TR2.TR_EmployeeID = TR.EmployeeID) > 0
0
 
wdosanjosConnect With a Mentor Commented:
Should be something like:

DELETE TR
WHERE TrainingID = 171
and exists (select 1 from TR as TR2 where TR2.EmployeeID = TR.EmployeeID and TR2.TrainingID = 113)
0
All Courses

From novice to tech pro — start learning today.