Subject RE: [firebird-support] Re: update from 2 tables
Author Alan McDonald
> --- In firebird-support@yahoogroups.com, "cbll_lam" <cbll_lam@...>
> wrote:
> >
> > Thank you for pointing out my mistake. I must mixing it up with
> > something else.
> >
> > It begs another question: how to do it in FB?
> >
> > Any suggestion will be appreciated.
> >
> > regards,
> > bill
> >

what about
update a set a.p=(select b.q from b where b.y=a.x);
Alan



>
> ... hence the non standard syntax from Access.
>
> In a normalised structure, it would be a very unusual query to have
> to run. Normally you would never have a field of B duplicated into
> table A, but rather define a foreign key and join when applicable.
>
> If for some reason beyond my comprehension you needed to do it, the
> easiest way to do it in Firebird is to use a stored procedure.
>
> ---
>
> set term ^ ;
> create procedure copythis
> as
> begin
> for
> select q, y
> from b
> into :q, :y
> do
> begin
> update a set p = :q where x = :y;
> end
> end
> ^
>
> set term ; ^
> commit;
> execute procedure copythis;
> commit;
>
> ---
>
> Adam
>