-
Insert table column to another table column in SQL
Posted by markzero on Sunday, November 20th, 2011
If you have an empty new table, and wanted to transfer IDs from another table you could do this:
INSERT INTO new_table (user_id) SELECT existing_table.ID FROM existing_table;
If you would like to preserve order you can just order by any column from existing table:
INSERT INTO new_table (user_id) SELECT existing_table.ID FROM existing_table ORDER BY existing_table.any_column;
;)
Share this story:
Leave a Reply
Useful Links
Categories
Archives














