Home > database > Consult a rights management table, have a little complicated
Consult a rights management table, have a little complicated
Time:10-01
This requirement involves two table, a table is a record user permissions, a rights management are listed in the table entry User permission form: Uid, fid, perm Permissions entry table: Fid, name, caption Now do rights management page, demand is: 1, if there is the user's permissions, the query, with the right join can do 2, if the user is not set permissions, the query all permissions entries, uid, perm columns such as blank, is to united query
First right, second to the question now is how to achieve? This article 2 requirements can be realized in a query so much the better
CodePudding user response:
Your user permissions list didn't set the permissions, fid is empty
SELECT A.u id, A.f id, Amy polumbo erm, B.n ame, biggest aption the FROM user permission form A, permissions entry table B WHERE ID=A.F b. ID - finds out has the permissions user corresponding permission UNION ALL SELECT A.u id, b. id, Amy polumbo erm, B.n ame, biggest aption the FROM user permission form A, permissions entry table B WHERE A.F ID IS NULL, the corresponding permissions users all permissions