15 messages in com.mysql.lists.mysqlRe: Multiple tables in delete stateme...
FromSent OnAttachments
Augey Mikus09 May 2002 07:45 
Jay Blanchard09 May 2002 07:57 
Augey Mikus09 May 2002 08:04 
Jay Blanchard09 May 2002 08:12 
Egor Egorov09 May 2002 08:15 
Paul DuBois09 May 2002 08:19 
Augey Mikus09 May 2002 08:21 
Paul DuBois09 May 2002 08:38 
Jay Blanchard09 May 2002 09:01 
Gelu Gogancea09 May 2002 09:04 
Augey Mikus09 May 2002 09:28 
Max Anderson09 May 2002 09:59 
Jay Blanchard09 May 2002 10:22 
Max Anderson09 May 2002 11:37 
Jay Blanchard09 May 2002 11:38 
Subject:Re: Multiple tables in delete statement on Mysql 3
From:Gelu Gogancea (gge@arctic.ro)
Date:05/09/2002 09:04:11 AM
List:com.mysql.lists.mysql

Hi,

You can use variable.

set @a:=0; --initialise select @a:=tablename.id from tablename,someothertable where tablename.id = someothertable.id; --load the variable "a" delete from tablename where tablename.id=@a;

Regards, Gelu

_____________________________________________________ G.NET SOFTWARE COMPANY

Permanent e-mail address : gg@gonetsoftware.com gelu@yahoo.com

if i say:

delete from tablename where tablename.id = someothertable.id;

mysql complains because there is no reference to someothertable; error: Unknown table 'someothertable' in where clause.

So how can I reference both tables without deleting from both tables?

Augey

Jay Blanchard wrote:

[snip] is a statement like this not supported on mysql 3 but is supported in mysql 4?

delete table1 from table1,table2 where table1.id = table2.id; [/snip]

DELETE FROM tablename WHERE table1.id = table2.id

You can only delete from one table at a time.

To request this thread, e-mail <mysq@lists.mysql.com> To unsubscribe, e-mail <mysql-unsubscribe-ggelu=arct@lists.mysql.com> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php