MySQL Forums
Forum List  »  Newbie

DELETE-Statement with IN
Posted by: stefan chrobak
Date: May 12, 2005 04:21AM

ahoi

i ' ve got a little problem with my DELETE-Statement
and i'm not a profession to see the mistake.

here is the Statement:

------------------------------------------------------
DELETE FROM kunden WHERE tournumber IN ( SELECT DISTINCT kunden.tournumber FROM kunden,kundentour WHERE kunden.tournumber != kundentour.tournumber )
------------------------------------------------------

i'm working with ADODB and a MySQL-Database 4.x

the error-message give out following :

-----------------------------------------------------

Execute failed with this STATEMENT:

DELETE FROM kunden WHERE tournumber IN ( SELECT DISTINCT kunden.tournumber FROM kunden,kundentour WHERE kunden.tournumber != kundentour.tournumber )

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT DISTINCT kunden.tournumber FROM kunden,kundentour WHERE

------------------------------------------------------

in table "kunden" is standing for each kunde a tournumber
and in "kundentour" is standing a produkt_id with a tournumber like this:
------------------------------------------------------
kundentour_id-datum-tournumber-produkt_id-bestellmenge
#2-12.05.2005-36-16-10
#3-12.05.2005-36-26-10
#4-12.05.2005-36-24-10
#5-12.05.2005-37-21-5
------------------------------------------------------

if the product will be deletet in kundentour and there is no other product
with the same tournumber, than everything from kunden where this tournumber
exist has also deletet with my bugy Statement.

it will be very nice if someone can tell me , what's wrong with my Construction!
Sorry for my bad english, with greetings from hamburg

stefan

Options: ReplyQuote


Subject
Written By
Posted
DELETE-Statement with IN
May 12, 2005 04:21AM
May 13, 2005 02:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.