我有一些表,users
(uid int
)和permission
(pid, permi
)和users_perm
(id, uid, pid
)
许可
1, 's1'
2, 's2'
3, 's3'
用户
1
2
3
4
我希望每位用户都给予他所有许可
答案 0 :(得分:0)
假设您的意思是所有用户都获得了所有权限,则以下内容应该有效:
INSERT INTO
[users_perm]
SELECT
[uid] = u.[uid]
, [pid] = p.[pid]
FROM
[users] u
, [permission] p
答案 1 :(得分:0)
insert into users_perm
Select ROW_NUMBER() over (order by u.uid), u.uid,p.id From users u cross join permission p