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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DELETE DATA FROM TABLE BASE ON OTHER TABLE 1

Status
Not open for further replies.

pelagic

Programmer
Nov 7, 2002
97
US
Hi there,

I have tableA, in table A I have the following serial number

SerialNo
1
2
3
4
5

in tableB I have the following serial number.
SerialNo
3
4
5
How would I delete 3 4 5 number from tableA but base on the value from tableB


Thanks,
 
If SerialNo is the primary key in TableB, this:
[tt]DELETE TableA.*
FROM TableA INNER JOIN TableB ON TableA.SerialNo = TableB.SerialNo;[/tt]
Should work.
 
Another way:
DELETE FROM tableA WHERE SerialNo IN (SELECT SerialNo FROM tableB)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top