Web Hosting Talk







View Full Version : New Delete Query in MySQL


jtrovato
04-25-2003, 04:26 AM
I want to create a single query to delete from 2 tables at once.

I know I can do it with 2 queries, but I want to take advantage of the new features in MySQL.

Tables
equipment
equipment_inter_table

Fields
equipment_id

The field is located in both tables and I want to delete the one record in the equipment DB and all the fields that have the ID in the equipment_inter_table


This is what I have so far:

DELETE FROM equipment as e ,equipment_inter_table as eit
WHERE e.equipment_id = eit.equipment_id AND e.equipment_id =40


Of course this doesn't work, I don't know how to modify this so it does work

Thanks

digitok
04-25-2003, 04:46 AM
Have a look here:
http://www.mysql.com/doc/en/DELETE.html
It explains about the DELETE function and deleting from multiple tables at once.

Hope it helps.

ilyash
04-25-2003, 11:41 PM
why not just do it in two?

sasha
04-26-2003, 12:29 AM
Originally posted by ilyash
why not just do it in two?

doh, whats fun about that.