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 table 2

Status
Not open for further replies.

JCAA

MIS
Jun 22, 2003
65
US
I know that this probably sounds like a very stupid question but I still need to ask as I don’t know the answer. I currently have a table with a lot of records I have another table with records that needs to be deleted from the first big table. How do I delete the records from the big table that are also in my smaller table, also not all fields are in the smaller table but it does have a common field to match up the records with. Thanks!
 
Delete * from BigTable
Where CommonField Not In (Select Distinct CommonField
From SmallTable) ;

The CommonField should be a unique identifier for each record.
 
Shouldn't it be

Delete * from BigTable
Where CommonField In (Select Distinct CommonField
From SmallTable)

I thought JCAA wanted to deleted all the records from the big table that DO exist in the smaller table?

Transcend
[gorgeous]
 
You're right.

Did I mention that it is a good idea to run an action query in datasheet view first so you can see what records are affected?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top