Subject | Re: Does Firebird support deletes, updates with subquery? |
---|---|
Author | lmmolinerocasares |
Post date | 2005-02-21T08:05:10Z |
Thanks Helen. Really the right answer.
I solved it with a stored procedure, but I wanted to know if it is
possible to do it with a subquery, and I think this is more elegant.
The detail: I have a database for nutritional calculus with a master
table of recipes and a detail table of ingredients, and I wanted to
update the recipes which have some ingredient, and your solution is
perfect.
Thanks again.
Luis M. Molinero
Las Rozas - Madrid (SPAIN)
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
I solved it with a stored procedure, but I wanted to know if it is
possible to do it with a subquery, and I think this is more elegant.
The detail: I have a database for nutritional calculus with a master
table of recipes and a detail table of ingredients, and I wanted to
update the recipes which have some ingredient, and your solution is
perfect.
Thanks again.
Luis M. Molinero
Las Rozas - Madrid (SPAIN)
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 07:35 PM 18/02/2005 +0000, you wrote:do in
>
> >Does Firebird support deletes and/or updates with subquery?.
> >Something like this:
> >
> >DELETE FROM RECIPES
> >WHERE R_ID = ( SELECT R_ID FROM INGREDIENTS
> > WHERE NAME='RICE' )
>
> DELETE FROM RECIPES R
> WHERE EXISTS
> (SELECT 1 FROM INGREDIENTS
> WHERE I.R_ID = R.R_ID
> AND I.NAME='RICE')
>
> And, yes, you can use a subquery in either the SET value or the search
> value of an update query. I can't offer a sensible example from your
> current example, though. Give some detail about what you'd want to
> such an update.
>
> ./heLen