Re: delete statement question
| From: | Bill Morrow | Date: | Mon, 25 Mar 2002 20:02:15 +0000 |
| Subject: | Re: delete statement question | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17896@lists.php.net to get a copy of this message | ||
On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote:
> Hi, I hope you can help me with this:
>
> I have these 3 tables.
>
> exam (
> exam_id
> )
>
> questions (
> question_id
> exam_id
> )
>
> answers (
> answer_id
> question_id
> )
>
> I am wondering if i can delete all the rows for answers linked to a given
> exam using only one delete statement.
>
> Thanks in advance,
>
> andres
>
delete answers
where question_id in (select question_id from questions where exam_id=X)
I assume there isn't a one-to-one relationship between questions and
answers? If there is, your database is overnormalized.