开发者

Copying the values from specific columns from an SQL table to another table

开发者 https://www.devze.com 2023-02-25 10:32 出处:网络
I have two Table开发者_运维知识库s: Users and Permission. They share 2 columns with the same name, so I need to copy values of those 2 columns from \'Users\' to \'Permission\'. However, since there is

I have two Table开发者_运维知识库s: Users and Permission. They share 2 columns with the same name, so I need to copy values of those 2 columns from 'Users' to 'Permission'. However, since there is a third column on Permission that cannot go blank, it needs to be filled with the value '0' by default.

See the diagram for further understanding:

Copying the values from specific columns from an SQL table to another table

What SQL command should I use to perform this feat?

Thanks!


insert into permission( userid, login, permission )
select UserId, login, 0 from users
0

精彩评论

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