I want to delete many tables on same time from database,how can I achieve such target? Is there any particular query or way to do so ?
            Asked
            
        
        
            Active
            
        
            Viewed 448 times
        
    1 Answers
1
            From the manual:
You can specify multiple tables in a
DELETEstatement to delete rows from one or more tables depending on the particular condition in theWHEREclause.Multiple-table syntax:
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
    tbl_name[.*] [, tbl_name[.*]] ...
    FROM table_references
    [WHERE where_condition]
For the multiple-table syntax,
DELETEdeletes from each tbl_name the rows that satisfy the conditions.For the first multiple-table syntax, only matching rows from the tables listed before the FROM clause are deleted. For the second multiple-table syntax, only matching rows from the tables listed in the FROM clause (before the USING clause) are deleted. The effect is that you can delete rows from many tables at the same time and have additional tables that are used only for searching:
DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;
Or:
DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;
 
    
    
        Kermit
        
- 33,827
- 13
- 85
- 121
- 
                    thanks, let me try it – ankit.jbp Mar 08 '13 at 14:32
