开发者

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

开发者 https://www.devze.com 2023-02-17 06:32 出处:网络
suppose I have a users table but with different structure, how could I import all the data into another one?

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

精彩评论

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