copy one to many?

From: Walt Bigelow <walt(at)stimpy(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: copy one to many?
Date: 1998-08-27 19:38:44
Message-ID: Pine.LNX.4.02.9808271237440.17500-100000@alice.stimpy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This is a follow up to my last question on how to use INSERT INTO to copy
rows. I have one more hurdle... how can I copy one or more source rows to
many dest rows, but with different target library numbers?

I have this:
INSERT INTO tblspotinfo
(librarynumber,
spotnumber,
spottitle,
isci,
trt,
starttimecode,
date,
audiotypeid)
SELECT
'6666',
spotnumber,
spottitle,
isci,
trt,
starttimecode,
date,
audiotypeid
FROM
tblspotinfo
WHERE
librarynumber = '9988';

Is there a way to say, get all records with the library number = '9988'
and copy them to a list of NEW library numbers?

So source would be librarynumber 9988,
and dest would be 4457, 4458, 4459, 4460 instead of 6666.

Is SQL capabile of this or do I need a function on the server side to do
this easily?

I'm kinda stuck, since the only docs I have on SQL is a crappy MS Access
'developers' book. :-(

Thanks,
Walt

Browse pgsql-sql by date

  From Date Subject
Next Message Bryan White 1998-08-27 19:56:22 Re: [SQL] copy one to many?
Previous Message ADM. Diego Cueva 1998-08-27 14:13:50 Counter