Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-20-2005, 11:36 AM   PM User | #1
tdmf
New Coder

 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
tdmf is an unknown quantity at this point
delete from multiple tables with join ?

Code:
$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 ?
tdmf is offline   Reply With Quote
Old 01-20-2005, 11:45 AM   PM User | #2
Kiwi
Regular Coder

 
Join Date: Oct 2002
Posts: 379
Thanks: 0
Thanked 0 Times in 0 Posts
Kiwi is an unknown quantity at this point
Read the documentation.

PHP Code:
DELETE table1,table2
FROM table1
,table2
WHERE table1
.id get['id']
  AND 
table2.id table1.id 
Note, I've joined the tables - otherwise doing them in a single query makes little sense.
__________________
Strategy Conscious
Kiwi is offline   Reply With Quote
Old 01-20-2005, 12:02 PM   PM User | #3
tdmf
New Coder

 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
tdmf is an unknown quantity at this point
Hmmmm.........still doesnt work.
PHP Code:
DELETE aa_db_surface2cityaa_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 !

Last edited by tdmf; 01-20-2005 at 01:04 PM..
tdmf is offline   Reply With Quote
Old 01-20-2005, 03:11 PM   PM User | #4
Kiwi
Regular Coder

 
Join Date: Oct 2002
Posts: 379
Thanks: 0
Thanked 0 Times in 0 Posts
Kiwi is an unknown quantity at this point
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.
__________________
Strategy Conscious
Kiwi is offline   Reply With Quote
Old 01-20-2005, 03:57 PM   PM User | #5
tdmf
New Coder

 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
tdmf is an unknown quantity at this point
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 ?
tdmf is offline   Reply With Quote
Old 01-20-2005, 04:52 PM   PM User | #6
tdmf
New Coder

 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
tdmf is an unknown quantity at this point
ok my mysql version is: 3.23.57 - blame my host

is there any way to delete entries in multiple tables for this version ?

thanks a lot !
tdmf is offline   Reply With Quote
Old 01-20-2005, 06:43 PM   PM User | #7
dniwebdesign
Regular Coder

 
dniwebdesign's Avatar
 
Join Date: Dec 2003
Location: Carrot River, Saskatchewan
Posts: 677
Thanks: 3
Thanked 2 Times in 2 Posts
dniwebdesign is an unknown quantity at this point
Do seperate queries back to back...
__________________
Dawson Irvine
CEO - DNI Web Design
http://www.dniwebdesign.com
dniwebdesign is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:33 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.