我在具有列 ( ) 的表中存储在数据库中的部分列表和具有列Sections( sectionId, sectionTypeId, sectionName) 的表中的权限。UserPrivilagesuserPrivilagesId, userId, sectionTypeId
我想从表中选择所有部分,Sections但将它们标记sectionTypes为sectionTypeId存储在UserPrivilagesby中userId。
就像是:
SELECT sectionId, sectionTypeId, sectionName, (true/false) as privilage
FROM Sections
如果我用表加入这个结果,UserPrivilages我得到的结果只存在于两个表中,但我还想拥有用户t have没有特权的部分。
UserPrivilages如果表存在于表中,则此 true/false 来自sectionTypeId表,否则返回 true,否则为 falseSectionsUserPrivilagesuserId
所以结果将是例如
SectionId sectionTypeId sectionName privilage
1 1 Name1 true or 1
2 2 Name2 false or 0