SELECT parentDocumentID FROM documents WHERE (siteID = ? or siteID is null or siteID = (select masterSiteId from sites where siteId = ? )) AND active = 1 AND ( NOT EXISTS ( SELECT * FROM roleAccess WHERE roleAccess.documentID = documents.documentID ) ) and documentID = ? AND activeFrom < CURRENT_TIMESTAMP AND activeUntil > CURRENT_TIMESTAMP ORDER BY [order],name;