关于union之后group by且留下isGroup为1的select

SELECT * FROM (
      SELECT ude.*,em.FirstName,em.StaffNo,em.LastName,1 AS isGroup FROM user_deny_emlpoyee AS ude
      LEFT JOIN employee_master AS em ON(ude.EmpID=em.EmpID)
      WHERE ude.UserID IN(SELECT GroupID FROM user_map_group WHERE UserID=1)
 UNION     
     SELECT ude.*,em.FirstName,em.StaffNo,em.LastName,0 AS isGroup FROM user_deny_emlpoyee AS ude
      LEFT JOIN employee_master AS em ON(ude.EmpID=em.EmpID)
      WHERE ude.UserID=1
      ) AS uni GROUP BY EmpID

你可能感兴趣的:(mysql)