Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: [SQL] How to merge two tables into one ?
On Wed, 08 Jul 1998 12:57:00 GMT, Zahi Al-Jamous
<aljamous_at_crv.pechiney.fr> wrote:
>Hi all,
>
>i have two tables structured like this :
>
>Table policy
> Id
> Number
> Customer
> Adress
>Table Commentary
> Id (foreign key references policy.Id)
> LineNumber
> Comment
>
>I want to have one table :
>table PolicyNew
> Id
> Number
> Customer
> Adress
> Comment
>
>Where "Comment" is the concatenation of all the "Comment" fields in
>table Commentary where Policy.Id = Commentary.Id
>
>Can someone help me writing this script ?
I think this is what you want...
begin
-- -- Move all the data from Policy to PolicyNew --
-- -- Move Comments by updating Policy New -- for x in ( select * from Commentary order by Id, LineNumber ) loop update PolicyNew set Comment = Comment || ' ' || x.Comment where id = x.id;
chris. Received on Wed Jul 08 1998 - 19:40:38 CDT
![]() |
![]() |