Delete Multiple Rows on a Many-to-Many Relationship Table

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
bwan37
Forum Newbie
Posts: 9
Joined: Thu May 22, 2008 11:42 am

Delete Multiple Rows on a Many-to-Many Relationship Table

Post by bwan37 »

Is it possible to Delete Multiple Rows on a Many-to-Many Relationship Table?

eg..
TABLE student_choice (
student_id int(3),
course_taken varchar(16),
PRIMARY KEY(student_id, course_taken)
}

Data:
student_id | course_taken
001 | math
001 | english
002 | math
002 | biology


I want to delete all of "001" record!
Can I do it in one simple delete statement?
Thanks for the help!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Delete Multiple Rows on a Many-to-Many Relationship Tabl

Post by Christopher »

You mean like this?:

DELETE FROM student_choice WHERE student_id='001'
(#10850)
bwan37
Forum Newbie
Posts: 9
Joined: Thu May 22, 2008 11:42 am

Re: Delete Multiple Rows on a Many-to-Many Relationship Tabl

Post by bwan37 »

Ouch!!! that's what I mean...
@_@ Thanks @_@
Post Reply