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

CodePudding user response:

reference 1st floor qq_39932185 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

Thank you, I may not be clear: if the user never set permissions, so do not have the record of the user permission form, so do not check with fid is null data

CodePudding user response:

That you also have a users table, otherwise how to know which user profile permissions, which users do not have any rights,

CodePudding user response:

reference RINK_1 reply: 3/f
that you also have a users table, otherwise how to know which user profile permissions, which users without any permission,

If there are no records in a permission form means never assign permissions:
  • Related