Subject RE: [firebird-support] Updating with inner join - noobie help needed
Author Lin XG
Hi Adam;

Thank you for taking the time to reply, however I'm
more confused than ever.

How would your query work if I had to update more than
one field, for example....

SET VT_TR_TABLE.DISTRI = VT_TR_CABLE_TABLE.CA,
VT_TR_TABLE.A = VT_TR_CABLE_TABLE.B and so on

How would I control the number of records updated.
Normally I would want to update all records in
VT_TR_TABLE that can be updated.

I'm not sure what you're getting at with the reference
to duplicate records. If for some reason the
MASTER_KEY in either table (they're unique) appeared
more than once would it not just possibly overwrite
existing information. I'm not sure how anything could
be duplicated?

What would SELECT FIRST 1 do?

Thanks again for all your help.
Lin


--- Alan McDonald <alan@...> wrote:

> >
> > Can someone please tell me what is wrong with this
> query.
> >
> > UPDATE VT_TR_TABLE
> > SET VT_TR_TABLE.DISTRI = VT_TR_CABLE_TABLE.CA FROM
> VT_TR_TABLE INNER
> > JOIN VT_TR_CABLE_TABLE ON
> > VT_TR_TABLE.MASTER_KEY =
> VT_TR_CABLE_TABLE.MASTER_KEY;
> >
> > When I try to run it it gives the following error.
> >
> > Token unknown FROM
> >
> > The query is supposed to update DISTRI to CA where
> the two master
> > keys match.
> >
> > Thanks for your help
> > Lin
> >
>
> use barckets ans the SELECT key word
>
> > UPDATE VT_TR_TABLE
> > SET VT_TR_TABLE.DISTRI = (select
> VT_TR_CABLE_TABLE.CA FROM VT_TR_TABLE
> INNER
> > JOIN VT_TR_CABLE_TABLE ON
> > VT_TR_TABLE.MASTER_KEY =
> VT_TR_CABLE_TABLE.MASTER_KEY);
>
> you may need to control the number of records
> updated though and watch for
> duplicates.. SELECT FIRST 1 may be required also.
> Alan
>
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com