John Rosenberg
John Rosenberg

Reputation: 617

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

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: enter image description here

What SQL command should I use to perform this feat?

Thanks!

Upvotes: 1

Views: 2462

Answers (1)

Randy
Randy

Reputation: 16673

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

Upvotes: 3

Related Questions