Page 1 of 1

1 line query to delete specific records from multiple table

Posted: Wed Dec 14, 2005 10:23 am
by mastikhor
On clients machine, currently to delete on trainee record it runs 10 queries to delete records from 10 tables. At the time of running all queries, server shows (104) Connection reset by peer. An error condition occurred while reading data from the network.

I think it because of running 10 queries at a same time. Is there any possibility that through one line of query we can delete record from 10 tables.

I've tried following query

DELETE FROM table1, table2, table3, table4, table5, table6, table7, table8, table9, table10 WHERE empID = 11;

But it gives ' error in query.

Any tip

Posted: Wed Dec 14, 2005 10:34 am
by Burrito
delete from multiple tables in single query you can not.

create a loop and run the query over each iteration of the loop you should.

Posted: Wed Dec 14, 2005 10:57 am
by ryanlwh
mysql.com wrote: In MySQL 4.0:

DELETE test FROM test AS t1, test2 WHERE ...

In MySQL 4.1:

DELETE t1 FROM test AS t1, test2 WHERE ...
you need to specify the tables to be deleted before FROM in a multiple table delete statement

Posted: Thu Dec 15, 2005 1:34 am
by mastikhor
I've tried that one. thats not a solution.

I've got to know that I've to create stored procedures