![]() |
SQL query question - Copy a column from one table to another
How can this be done ?
Background: One table, articles_article has already been created, with rows having the first column articles_articleid, being the unique id for each row. I want to create another table, articles_newtable with exactly the same number of rows with each row having the same corresponding articles_articleid. How can this be achieved ? Thanks in advance :) |
that way should work:
[sql] INSERT INTO articles_newtable (articleid) SELECT articles_articleid FROM articles_article[/sql] so you see you can mix up insert an select queries :) |
I never knew that ! Thanks Stefan :D
|
you're welcome
|
A similar technique can be used to copy table contents over within or even between databases.
[sql]create table destinationdatabase.newtable select * from sourcedatabase.oldtable[/sql] You don't have to specificy databases if making a transfer within the same database. |
hey, that one was even new to me :)
you see you can learn more every day.. |
This is an enlightening thread :)
|
All times are GMT. The time now is 12:45 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|