Forum Moderators: coopster

Message Too Old, No Replies

Deleting rows across multiple tables

is there an easy way?

         

willybfriendly

7:29 pm on Feb 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using MySQL. Documentation is not clear to me, and it remains clear after doing some searching.

I know this does NOT work

DELETE FROM table1,table2,table3,table4 WHERE dataID='id';

Do I really need to run 4 queries? Seems awfully inefficient.

WBF

willybfriendly

4:38 am on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bump?

I am using multiple queries for now, but would still like to know...

WBF

coopster

1:37 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Actually, that will work, from MySQL > 4.0.

You can specify multiple tables in the

[url=http://www.mysql.com/doc/en/DELETE.html]DELETE[/url]
statement to delete rows from one or more tables depending on a particular condition in multiple tables. However, you cannot use
ORDER BY
or
LIMIT
in a multiple-table
DELETE
.

willybfriendly

4:22 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm... does this mean I need to upgrade this machine of mine?

Thanks!

WBF