Reputation: 617
I have two Tables: 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!
Upvotes: 1
Views: 2462
Reputation: 16673
insert into permission( userid, login, permission )
select UserId, login, 0 from users
Upvotes: 3