Skip to content

Instantly share code, notes, and snippets.

@mspreij
Last active April 6, 2018 13:57
Show Gist options
  • Save mspreij/81841b4a0f9eb1a36e20955d2320536c to your computer and use it in GitHub Desktop.
Save mspreij/81841b4a0f9eb1a36e20955d2320536c to your computer and use it in GitHub Desktop.
/*
We have a table with read/write permissions for every User Role / Object Type / Object Property.
When adding a new Property to an object we often copy the rights from an existing, similar property, with this query:
*/
INSERT INTO rights (roleId, strType, strProperty, `read`, `write`)
SELECT roleId, strType, newProperty, `read`, `write`
JOIN (SELECT 'new property one' AS newProperty UNION SELECT 'new property two' UNION SELECT 'new property three')
FROM rights
WHERE strType = 'phdRegistrations'
AND strProperty = 'existingProperty';
-- if we want to do this for 10 new properties (say), is there a shorter way than copy/pasting this 10 times?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment