Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Downgrade Delete Statement From 4.0 -> 3.32, Help Pls! 2

Status
Not open for further replies.

RaffiqEddy

Programmer
Jan 7, 2002
51
0
0
MY
Hi,

I want to delete all data from Table1 based on data from Table2.

So do as following:
Code:
DELETE Table1
FROM Table1
INNER JOIN Table2 ON 
Table1.StatusId = Table2.StatusId AND
Table1.ApproveById = Table2.ApproveById AND
Table1.EmpNo = Table2.EmpNo
Using MySQL 4.0 on my PC it works perfectly.

BUT the problem with my Server which using MySQL 3.32, it returns with an error.

Can someone help me to DOWNGRADE the query above from MySQL 4.0 --> 3.32

TIA

Regards.
 
I think older versions of MySQL didn't support the INNER JOIN ... ON syntax.

Try using instead:
[tt]
DELETE Table1
FROM Table1,Table2
WHERE
Table1.StatusId = Table2.StatusId
AND Table1.ApproveById = Table2.ApproveById
AND Table1.EmpNo = Table2.EmpNo
[/tt]
 
I have tried that, but still not working... I also do as following but still not working..

Code:
DELETE FROM Table1
USING Table1,Table2
WHERE
Table1.StatusId = Table2.StatusId AND
Table1.ApproveById = Table2.ApproveById AND
Table1.EmpNo = Table2.EmpNo

Anyone have other solution??

TIA
 
Code:
DELETE Table1
FROM Table1,Table2
WHERE
  Table1.StatusId = Table2.StatusId
  AND Table1.ApproveById = Table2.ApproveById
  AND Table1.EmpNo = Table2.EmpNo

#1064 - You have an error in your SQL syntax near 'Table1 FROM Table1, Table2 WHERE Table1.StatusId' at line 1

Code:
DELETE FROM Table1
USING Table1,Table2
WHERE
Table1.StatusId = Table2.StatusId AND
Table1.ApproveById = Table2.ApproveById AND
Table1.EmpNo = Table2.EmpNo

#1064 - You have an error in your SQL syntax near 'USING Table1,Table2 WHERE Table1.StatusId = Table2.' at line 1
 

the best you can do is run a join query to produce a list of primary keys that qualify for deletion, then use the generated list in a DELETE statement

DELETE from Table1 where pkey in ( 123, 234, 345, 456, ... 937 )


r937.com | rudy.ca
 
Oh well, I knew this will come...

BTW, a star for both of you, excellent helper...

Take care,

Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top