getuserallL.sql 629 B

12345678910111213141516171819202122232425262728
  1. SELECT
  2. `user`.id,
  3. `user`.username,
  4. `user`.`empid`,
  5. `user`.`deviceId`,
  6. emp.`empname`,
  7. dept.`name` deptname,
  8. user.sort,
  9. user.enable,
  10. user.keeper,
  11. user.maintenancePerson,
  12. GROUP_CONCAT(r.`name`) roleName
  13. FROM
  14. user
  15. LEFT JOIN emp
  16. ON emp.id = `user`.`empid`
  17. LEFT JOIN department AS dept
  18. ON dept.id = emp.deptid
  19. LEFT JOIN user_role ur
  20. ON `user`.id = ur.user_id
  21. LEFT JOIN role r
  22. ON ur.role_id = r.id
  23. WHERE (emp.pastureId = ?
  24. OR ? = 18)
  25. AND (`user`.username like concat('%',?,'%') OR ? = '')
  26. AND (emp.`empname` like concat('%',?,'%') OR ? = '')
  27. GROUP BY `user`.empid
  28. ORDER BY user.sort