SELECT
  SI.RightDescription,
  IF((SUM(IF((X.UserID IS NOT NULL) AND (X.UserID = @nUserID), 1, 0))) > 0, 'YES', 'no') AS HasRight
FROM
  taSystemRight AS SI
    LEFT JOIN taRoleRightLink AS Y ON (Y.RightName = SI.RightName)
    LEFT JOIN taUserRoleMember AS X ON (X.RoleName = Y.RoleName)
GROUP BY
  SI.RightName,
  SI.RightDescription
ORDER BY
  SI.RightOrder