Inserting using existing row data
Date: 15 Jul 1993 06:57:43 -0700
Message-ID: <223non$b9c_at_spock.dis.cccd.edu>
Hi, another SQL question that I hope is not an FAQ.
My question deals with inserting a row into a table using values from an existing row within the same table. I know I can use the SELECT statement to grab values from another row within the INSERT statement itself. What I'd like is to be able to select all columns from an existing row except the key column and insert their values along with a new key value into a new row. However, to keep my application from having to know about the structure of the table (except the key column name), is there a way I can code the INSERT/SELECT statement combination without having to use any column names (maybe just the "*") other than the key column name?
Example:
table_a
key_col col_1 col_2
...
col_n
INSERT INTO table_a
SELECT 2,col_1,col_2,...,col_n FROM table_a WHERE key_col = 1
Is it possible to perform this type of statement without having to specify 'col_1,col_2,...,col_n', but using something generic to represent them?
Any suggestions or am I just dreaming?
Thank you in advance for any help.
-- Paul Krikorian | Internet: paulk_at_spock.dis.cccd.edu Coast Community College District | Voice: (714) 432-5150 1370 Adams Ave. | Fax: (714) 432-5062 Costa Mesa, CA 92626, USA |Received on Thu Jul 15 1993 - 15:57:43 CEST