• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

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)
0
rocky050371
Asked:
rocky050371
1 Solution
 
Habib PourfardCommented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now