wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes DELETE SQL Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DELETE SQL Question" Watch "DELETE SQL Question" New topic


Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
So I have two tables, A and B, and I'd like to delete all records from A in which two of the columns match two columns in B - here's what my tables look like:

There are more columns in each table, but these are the ones I'd like to matc upon. When all is said and done, I'd like table A to look like this:

I'm a little unsure on how to write the SQL. I think I can do this:

I think that'll work, but I don't really like the syntax. It just doesn't seem obvious to me what that query will do and I'd like to have somewhat more readable SQL.

Any advice on a straightforward way to do this deletion?


SCJP Tipline, etc.
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Delete FROM mytable A
FROM myothertable B
WHERE A.PersonID = B.PersonID
AND A.ServiceID = B.ServiceID)
[ November 08, 2007: Message edited by: Paul Campbell ]
I agree. Here's the link: http://aspose.com/file-tools
subject: DELETE SQL Question
It's not a secret anymore!