Subject | Re: update from 2 tables |
---|---|
Author | cbll_lam |
Post date | 2006-06-23T05:55:40Z |
> what aboutI did not try but it looks strange. Does it actually work?
> update a set a.p=(select b.q from b where b.y=a.x);
> Alan
> > ... hence the non standard syntax from Access.I checked again, I used that syntax in MS SQL Serser not FB.
> >
As SQL Server has it root from sybase, I googled and found that it is
also supported, but must turn ansi compliance off.
http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0901/en/html/dbrfen9/00000498.htm
> > In a normalised structure, it would be a very unusual query to haveYes, I use un-normalised structure for efficiency and reporting.
> > 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, theThank you! I will try later because I've never used SP in FB before.
> > 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;
> >
regards,
bill