How do I copy one colum to another new tables
Example my table structure
current_db
ID email name address phone
---------------------------------------------
1 email@email.com John My Address 123456789
2 email@email.net开发者_如何学Python Peter My Address 123456721
new_db
ID email column1 column2 column3 column4
------------------------------------------
How do I copy only email address from current_db
to new_db
.
Think I mis-understood... early for me. You mentioned from one database to another, not table to table.
If the tables were actually kept in separate "databases", such as rebuilding, or porting to a new database from an old and you were restructuring tables.... You would have to prefocus to the new database and create your table from an insert of the column desired from database.table from another.
use New_db
create table x select email from Other_Db.YourTable
However, from re-reading and seeing the other answer, that's probably closer to what you want
insert into OneTable ( columnX, columnY, columnZ ) values select x, y, z from OtherTable where...
Use the INSERT … SELECT
syntax:
INSERT INTO `new_db` ( `email` )
SELECT `email` FROM `current_db`
精彩评论