SQL Question

I have the following


DELETE
FROM Parameter WHERE PARAM_ID NOT IN (SELECT PARAM_ID FROM CallbackParameter)

here is the current table structure

Callback ----  CallbackParameter --- Parameter
Trigger ----- TriggerParameter --- Parameter


I need to ensure on delete the parameter table is clear of non linked parameters


Can I do something like

DELETE
FROM Parameter WHERE PARAM_ID NOT IN (SELECT PARAM_ID FROM CallbackParameter UNION SELECT PARAM_ID FROM TriggerParameter)
rocky050371Asked:
Who is Participating?
 
Habib PourfardConnect With a Mentor Software DeveloperCommented:
Yes you can do it. the query you've wrote is ok.
0
 
aplusexpertCommented:
Yes, your query is right.
0
 
CluskittCommented:
When in doubt, create your delete/update queries as a select:
SELECT *
FROM Parameter WHERE PARAM_ID NOT IN (SELECT PARAM_ID FROM CallbackParameter UNION SELECT PARAM_ID FROM TriggerParameter)

When you're happy with the results, then you can change the select into a delete.
0
 
Sushil SonawaneCommented:
You can do it. What you writtern query is right.
0
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.