开发者

How could I import a existent users table into another one with different structure?

suppose I have a users table but with different structure, how could I import all the data into another one?

lets say I have:

users:
- id
- name
- created_at
- updated_at

and another one already populated with:

users:
- id
- login
- created_at
- updated_at

its just a s开发者_Python百科ample to easy visualization.

Any help is appreciated!


Take a look at insert into select

http://dev.mysql.com/doc/refman/5.0/en/insert-select.html


INSERT INTO users2 
            (LOGIN, 
             created_at, 
             updated_at) 
SELECT name, 
       created_at, 
       updated_at 
FROM   users1 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜