Subject Re: [firebird-support] Help with a DELETE command
Author Helen Borrie
At 01:04 PM 5/12/2004 -0800, you wrote:

>Without using ON DELETE or Triggers, how can I best do the following?
>
> DELETE
> FROM Child JOIN Parent ON Child.F_ID = Parent.F_CHILD_ID
> WHERE Parent.F_FOO = 1;
>
>I know the above is illegal, but it captures the query I would like to
>delete with. I tried the following but for some reason it locked up the
>database completely -- not even an error message:
>
> DELETE
> FROM Child
> WHERE Child.F_ID
> IN (SELECT Parent.F_CHILD_ID FROM Parent WHERE
>Parent.F_FOO = 1);
>
>Any thoughts?

DELETE FROM Child c
WHERE EXISTS(
SELECT 1 FROM Parent p
WHERE p.F_CHILD_ID = c.F_ID AND p.F_FOO = 1)

./hb