I have a table called table1 within oracle DB that looks like this:
ID USERID FRUIT COLOR
1 10 APPLE BLUE
2 10 ORANGE RED
3 20 BANANA YELLOW
I would like to build a query that would: - select all rows from userID 10 and copy them over to the same table, keeping all fields untouched apart from ID (I would guess it should automatically increment itself?). Edit: The increment part will increment itself as long as it is DB column (not user created).
So the result I would like to have is for userID 20 to have userID 10 rows as per below:
ID USERID FRUIT COLOR
1 10 APPLE BLUE
2 10 ORANGE RED
3 20 BANANA YELLOW
4 20 APPLE BLUE
5 20 ORANGE RED
Below is my trial query - will it work?
INSERT INTO table1
SELECT * FROM table1
WHERE USERID=10;