Assumption is that you want to delete the records in RULES table.
Perhaps the following, but I WOULD back up your data before I even tried
this.
If it fails, then try to get just one section of the Where clause to
work and then once you get that to work you can duplicate it for the
other three sections
DELETE
FROM RULES
WHERE
Rules.DoName in
(SELECT Device.DeviceName
FROM Device
WHERE DeviceType.DeviceTypeID=20)
OR Rules.Name1 in
(SELECT Device.DeviceName
FROM Device
WHERE DeviceType.DeviceTypeID=20)
Or Rules.Name2 in
(SELECT Device.DeviceName
FROM Device
WHERE DeviceType.DeviceTypeID=20)
Or Rules.Name3 in
(SELECT Device.DeviceName
FROM Device
WHERE DeviceType.DeviceTypeID=20)
This may get more records than you want if there has to be related
records in the DeviceClass and DeviceType tables for records in the
Device table.
If so, you will need to add the tables back in to the where
clause like so.
WHERE Rules.DO in
(SELECT Device.DeviceName
FROM (Device INNER JOIN (DeviceClass INNER JOIN DeviceType ON
DeviceClass.DeviceClassID=DeviceType.DeviceClassID) ON
Device.DeviceTypeID=DeviceType.DeviceTypeID)
WHERE DeviceType.DeviceTypeID=20)
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================