I have three tables I'm working with: Roles, Permissions, & RolePermissions (which links the two tables together. It has two columns: RoleId and PermissionId).
I added a new row to Permissions so I need to make it to where any role that has a permission = 117 is also equal to the latest permission that I just created (which could be any number). For example, say you have the role of adviser that has permission 117, then you automatically have this new permission (which is the max(id))
This is the code I tried:
INSERT INTO RolePermissions
VALUES
(
(SELECT RoleId FROM RolePermissions WHERE PermissionID = '117'),
(select max(id) from Permissions)
);
It says:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I believe it's because there are multiple roles that = 117 so it needs to make multiple rows. I'm a n00b and unsure how to make it multiple rows, would I use a loop?
Thanks