View Full Version : delete from multiple tables with join ?
$queryDelete = "
DELETE FROM table1,table2
WHERE table1.id=".$_GET['id']."
AND table2.id=".$_GET['id'];
Looks ok, but doesnt work.....$_GET['id'] is read correctly and available in all tables.....
any clues ?
Read the documentation (http://dev.mysql.com/doc/mysql/en/DELETE.html).
DELETE table1,table2
FROM table1,table2
WHERE table1.id = get['id']
AND table2.id = table1.idNote, I've joined the tables - otherwise doing them in a single query makes little sense.
Hmmmm.........still doesnt work.
DELETE aa_db_surface2city, aa_db_surface2contact
FROM aa_db_surface2city, aa_db_surface2contact
WHERE aa_db_surface2city.cSurfaceID=".$_GET['id']."
AND aa_db_surface2contact.cSurfaceID = aa_db_surface2city.cSurfaceID";
Please help !
Thank you !
What version of mySql are you using - it needs to be version 4 or greater (the details are in the docs). Otherwise that statement appears to be the correct syntax.
I would try hand coding the SQL into the command line and checking that it actually executes.
the console gives me the following error:
#1064 - You have an error in your SQL syntax near 'aa_db_surface2city,*aa_db_surface2contact
FROM aa_db_surface2city,*aa_db_surfa' at line 1
The documentations refers to the error as follows:
Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d
Now what does that tell me ?
ok my mysql version is: 3.23.57 - blame my host :confused:
is there any way to delete entries in multiple tables for this version ?
thanks a lot !
dniwebdesign
01-20-2005, 06:43 PM
Do seperate queries back to back...
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.