Deleting records in one table having a matching related record in another table?

Deleting records in one table having a matching related record in another table?

Post by MLH » Fri, 28 Jul 2006 00:06:33


DELETE tblPreliminaryVINs.* FROM tblPreliminaryVINs INNER JOIN
tblVehicleJobs ON tblPreliminaryVINs.PVIN = tblVehicleJobs.SerialNum;
The above SQL does not work for me. I get an error
I cannot delete the record(s) because of READONLY
and PERMISSIONS related issues.

I can hilite (select) the record in the table and delete it. I can
use the following SQL to delete record(s) in tblPreliminaryVINs
DELETE tblPreliminaryVINs.* FROM tblPreliminaryVINs;

But I really only want to delete records in tblPreliminaryVINs whose
[PVIN] field has a matching value somewhere in blVehicleJobs's
[SerialNum] field. How do I construct that SQL?
 
 
 

Deleting records in one table having a matching related record in another table?

Post by Rich » Fri, 28 Jul 2006 00:13:09

try it this way:

DELETE * from FROM tblPreliminaryVINs Where PVIN In (Select SerialNum
From tblVehicleJobs)


Rich

*** Sent via Developersdex http://www.yqcomputer.com/ ***

 
 
 

Deleting records in one table having a matching related record in another table?

Post by MLH » Fri, 28 Jul 2006 07:47:20

That was perfect, Rich. Many thx.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx