Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete from X where x.ID=(Select from Y where y.id=123) 1

Status
Not open for further replies.

benlinkknilneb

Programmer
May 16, 2002
590
US
Does anyone know a good way to accomplish this?

I have a table (X) which has a primary key. This is referenced in another table (Y) that has its own primary key.

I want to delete everything in X that's related to Y, given Y's primary key.

I'm writing a VB app to feed the SQL to the database, so it's possible for me to loop through them all but I was hoping that someone with better SQL-fu than I could craft a statement to handle it.

Ben
Windows isn't the answer; it's the question. NO is the answer.
 
Close. Try:

delete from X where x.ID in (Select x_id from Y where y.id=123);
 
Perfection. Have a star.

Ben
Windows isn't the answer; it's the question. NO is the answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top