Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sql statment
update table_one
set table_one.type =
(select table_two.type
from table_two where table_two.id = table_one.id)That will work if both tables use id as unique. Otherwise you must write the logic on table 2 to decide which record to use. You could use DISTINCT if you are sure table two can have multiple recs per id but the TYPE will be the same. Good luck! rq
Dennis L. Baker wrote:
> It has been a long time since I have used SQL...
> this is so basic I am embarrassed to ask.
>
> I want to update one tables field with data from a other tables field.
>
> both tables may have identical values in the "id" field, but will have
> different values
> in the "type" field, I will want to use the first value of "type" from the
> table_two database
> for (if they exist) all of the "type" fields with matching "id" fields in
> table_one
>
> the id field is the field i will use to match the data
>
> I could use the "group by id having count > 1" I think
>
> like....
>
> update table_one
> set table_one.type = table_two.type
> where table_one.id like table_two.id
>
> I always get a "ORA-00904: invalid column name" error
>
> please help or better yet explain "how to" as I would like to understand
> SQL.
>
> dlb
Received on Wed Nov 18 1998 - 05:33:25 CST
![]() |
![]() |