Copying the values from specific columns from an SQL table to another table
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:
What SQL command should I use to perform this feat?
Thanks!
insert into permission( userid, login, permission )
select UserId, login, 0 from users
精彩评论