SELECT `user`.id, `user`.username, `user`.`empid`, `user`.`deviceId`, emp.`empname`, dept.`name` deptname, user.sort, user.enable, user.keeper, user.maintenancePerson, GROUP_CONCAT(r.`name`) roleName FROM user LEFT JOIN emp ON emp.id = `user`.`empid` LEFT JOIN department AS dept ON dept.id = emp.deptid LEFT JOIN user_role ur ON `user`.id = ur.user_id LEFT JOIN role r ON ur.role_id = r.id WHERE (emp.pastureId = ? OR ? = 18) AND (`user`.username like concat('%',?,'%') OR ? = '') AND (emp.`empname` like concat('%',?,'%') OR ? = '') GROUP BY `user`.empid ORDER BY user.sort