Need help with a DELETE Syntax for Mysql

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
WizyWyg
Forum Commoner
Posts: 92
Joined: Tue Aug 06, 2002 7:20 pm

Need help with a DELETE Syntax for Mysql

Post by WizyWyg »

I am trying to delete records from two different tables at one time.

In event table I have eventid and eventname
in participants table I have eventid and name

participants table associates who will be attending events in table 1. So eventid = eventid for how many people are attending.

What would be the delete syntax for Mysql, if I want to delete from table event eventid=1 and all those associated in the participants table where eventid=1

I know that these work:
DELETE FROM participants WHERE eventid=1
DELETE FROM event WHERE eventid=1

How can i combine the two?

running with MySQL 3.23.47
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You have to run two DELETE queries, you delete from two tables at the same time using MySQL 3.23:
http://www.mysql.com/doc/en/DELETE.html
MySQL docs wrote:The first multi-table delete format is supported starting from MySQL 4.0.0. The second multi-table delete format is supported starting from MySQL 4.0.2.
Mac
Post Reply