A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problems with Delete Query



 
 
Thread Tools Display Modes
  #1  
Old September 13th, 2005, 10:39 AM
MarkS
external usenet poster
 
Posts: n/a
Default 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  
Old September 13th, 2005, 01:10 PM
giorgio rancati
external usenet poster
 
Posts: n/a
Default

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  
Old September 13th, 2005, 01:25 PM
giorgio rancati
external usenet poster
 
Posts: n/a
Default

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  
Old September 13th, 2005, 01:36 PM
MarkS
external usenet poster
 
Posts: n/a
Default

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  
Old September 13th, 2005, 02:57 PM
external usenet poster
 
Posts: n/a
Default


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 01:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.