If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Problems with Delete Query
I am confused with the following Query. I would like to delete all records
where the ITNO, PO, Line, and Vendor fields are the same in two tables. DELETE FROM tblReleased WHERE ( ITNO IN (SELECT ITNO FROM tblEmailedLines) AND PO IN (SELECT PO FROM tblEmailedLines) AND LINE IN (SELECT LineNumber FROM tblEmailedLines) AND VCODE IN (SELECT VendorCode FROM tblEmailedLines) ) However the code seems to be deleting virtually all records and I cannot figure out the logic. Can anybody shed some light on this or a better way of constructing the Query. Thanks in advance |
#2
|
|||
|
|||
Hi MarkS,
---- DELETE DISTINCTROW tblReleased.* FROM tblReleased INNER JOIN tblEmailedLines ON (tblReleased.ITNO = tblEmailedLines.ITNO) AND (tblReleased.PO = tblEmailedLines.PO) AND (tblReleased.VCODE = tblEmailedLines.VCODE) AND (tblReleased.LINE = tblEmailedLines.LINE); ---- Bye Giorgio "MarkS" ha scritto: I am confused with the following Query. I would like to delete all records where the ITNO, PO, Line, and Vendor fields are the same in two tables. DELETE FROM tblReleased WHERE ( ITNO IN (SELECT ITNO FROM tblEmailedLines) AND PO IN (SELECT PO FROM tblEmailedLines) AND LINE IN (SELECT LineNumber FROM tblEmailedLines) AND VCODE IN (SELECT VendorCode FROM tblEmailedLines) ) However the code seems to be deleting virtually all records and I cannot figure out the logic. Can anybody shed some light on this or a better way of constructing the Query. Thanks in advance |
#3
|
|||
|
|||
Ops ,
I confused two names of fields --- DELETE DISTINCTROW tblReleased.* FROM tblReleased INNER JOIN tblEmailedLines ON (tblReleased.ITNO = tblEmailedLines.ITNO) AND (tblReleased.PO = tblEmailedLines.PO) AND (tblReleased.VCODE = tblEmailedLines.VendorCode) AND (tblReleased.LINE = tblEmailedLines.LineNumber); ---- bye Giorgio "giorgio rancati" ha scritto: Hi MarkS, ---- DELETE DISTINCTROW tblReleased.* FROM tblReleased INNER JOIN tblEmailedLines ON (tblReleased.ITNO = tblEmailedLines.ITNO) AND (tblReleased.PO = tblEmailedLines.PO) AND (tblReleased.VCODE = tblEmailedLines.VCODE) AND (tblReleased.LINE = tblEmailedLines.LINE); ---- Bye Giorgio "MarkS" ha scritto: I am confused with the following Query. I would like to delete all records where the ITNO, PO, Line, and Vendor fields are the same in two tables. DELETE FROM tblReleased WHERE ( ITNO IN (SELECT ITNO FROM tblEmailedLines) AND PO IN (SELECT PO FROM tblEmailedLines) AND LINE IN (SELECT LineNumber FROM tblEmailedLines) AND VCODE IN (SELECT VendorCode FROM tblEmailedLines) ) However the code seems to be deleting virtually all records and I cannot figure out the logic. Can anybody shed some light on this or a better way of constructing the Query. Thanks in advance |
#4
|
|||
|
|||
Thank you Giorgio for your help with this.
Mark "giorgio rancati" wrote: Ops , I confused two names of fields --- DELETE DISTINCTROW tblReleased.* FROM tblReleased INNER JOIN tblEmailedLines ON (tblReleased.ITNO = tblEmailedLines.ITNO) AND (tblReleased.PO = tblEmailedLines.PO) AND (tblReleased.VCODE = tblEmailedLines.VendorCode) AND (tblReleased.LINE = tblEmailedLines.LineNumber); ---- bye Giorgio "giorgio rancati" ha scritto: Hi MarkS, ---- DELETE DISTINCTROW tblReleased.* FROM tblReleased INNER JOIN tblEmailedLines ON (tblReleased.ITNO = tblEmailedLines.ITNO) AND (tblReleased.PO = tblEmailedLines.PO) AND (tblReleased.VCODE = tblEmailedLines.VCODE) AND (tblReleased.LINE = tblEmailedLines.LINE); ---- Bye Giorgio "MarkS" ha scritto: I am confused with the following Query. I would like to delete all records where the ITNO, PO, Line, and Vendor fields are the same in two tables. DELETE FROM tblReleased WHERE ( ITNO IN (SELECT ITNO FROM tblEmailedLines) AND PO IN (SELECT PO FROM tblEmailedLines) AND LINE IN (SELECT LineNumber FROM tblEmailedLines) AND VCODE IN (SELECT VendorCode FROM tblEmailedLines) ) However the code seems to be deleting virtually all records and I cannot figure out the logic. Can anybody shed some light on this or a better way of constructing the Query. Thanks in advance |
#5
|
|||
|
|||
MarkS wrote: I would like to delete all records where the ITNO, PO, Line, and Vendor fields are the same in two tables. DELETE FROM tblReleased WHERE ( ITNO IN (SELECT ITNO FROM tblEmailedLines) AND PO IN (SELECT PO FROM tblEmailedLines) AND LINE IN (SELECT LineNumber FROM tblEmailedLines) AND VCODE IN (SELECT VendorCode FROM tblEmailedLines) ) However the code seems to be deleting virtually all records and I cannot figure out the logic. DELETE FROM tblReleased WHERE EXISTS ( SELECT * FROM tblEmailedLines WHERE tblEmailedLines.ITNO = tblReleased.ITNO AND tblEmailedLines.PO = tblReleased.PO AND tblEmailedLines.LineNumber = tblReleased.LINE AND tblEmailedLines.VendorCode = tblReleased.VCODE ); |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Toolbars, Drop-Down Menus | Rick | New Users | 1 | September 21st, 2005 11:17 AM |
Delete Query problems | quixote | Running & Setting Up Queries | 4 | August 12th, 2005 12:52 AM |
Delete query won't run! | faramir | Running & Setting Up Queries | 7 | February 7th, 2005 03:26 AM |
Here's a shocker | Mike Labosh | General Discussion | 2 | October 26th, 2004 05:04 PM |
delete records that have two fields with the same value | L. T. Portella | New Users | 9 | May 14th, 2004 05:49 PM |