Reputation: 21
I am trying to select all rows of table A and then duplicate all the rows in Table A while changing 1 field. Please find an example below along with the code I already wrote.
SELECT COLA, COLB, COLB
FROM TABLE A.
I want my end result to look like the following...
COLA COLB COLC
1234 test 01
1234 test 02
9876 testing 01
9876 testing 02
Upvotes: 0
Views: 51
Reputation: 1418
Something like this should work:
INSERT INTO A (COLA, COLB, COLC)
SELECT
COLA, 'testing', COLC
FROM A
I assume that you wanted to change column B from 'test' to 'testing'. If COLA is your primary, autoincremented key than just put NULL instead of COLA in SELECT to avoid duplicated keys.
Upvotes: 1