1 line query to delete specific records from multiple table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mastikhor
Forum Newbie
Posts: 12
Joined: Fri Nov 11, 2005 5:33 am

1 line query to delete specific records from multiple table

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
ryanlwh
Forum Commoner
Posts: 84
Joined: Wed Sep 14, 2005 1:29 pm

Post 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
mastikhor
Forum Newbie
Posts: 12
Joined: Fri Nov 11, 2005 5:33 am

Post by mastikhor »

I've tried that one. thats not a solution.

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