Results 1 to 2 of 2
Thread: Multi Table Deletes
Oct 28, 2010, 01:41 #1
- Join Date
- Jan 2006
- 0 Post(s)
- 0 Thread(s)
Multi Table Deletes
I'm trying (once again) to delete from multiple tables which are linked by the same primary id.
DELETE GAME_CONFIG_INITIAL_BUILDINGS.*,GAME_CONFIG_INITIAL_LAND.*,GAME_CONFIG_INITIAL_RESOURCES.* FROM GAME_CONFIG_INITIAL_BUILDINGS,GAME_CONFIG_INITIAL_LAND,GAME_CONFIG_INITIAL_RESOURCES WHERE GAME_CONFIG_INITIAL_LAND.game_config_id=GAME_CONFIG_INITIAL_RESOURCES.game_config_id AND GAME_CONFIG_INITIAL_RESOURCES.game_config_id=GAME_CONFIG_INITIAL_BUILDINGS.game_config_id AND GAME_CONFIG_INITIAL_RESOURCES.game_config_id='1'
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
Is there a quicker way of getting what I want done without so much garbage in my clause?
Oct 28, 2010, 04:08 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 60 Post(s)
- 3 Thread(s)
there are three ways
1. delete individually from each table one at a time
2. use cascading deletes (requires innodb and foreign keys)
3. use a multi-table joined delete
you're working on the 3rd, and the part you're missing is that the word DELETE must be followed immediately by the word FROM (unless you want one of those optional keywords), and the USING clause is where you do the joins