Quantcast
Channel: mysql "and" logic within result set - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Sarath Chandra for mysql "and" logic within result set

$
0
0

I agree that this might be looked down as a very inefficient/hacky way of doing things, but this should still get the job done. And frankly, I can't see any other way out of this.

SELECT * FROM (
  SELECT EMPLOYEE_ID, GROUP_CONCAT(DISTINCT EmployeeType ORDER BY EmployeeType) AS Roles 
  FROM EMPLOYEES GROUP BY EMPLOYEE_ID
) EMPLOYEE_ROLES
WHERE EMPLOYEE_ROLES.Roles = 'CEO,Developer,Manager';

Note that the comma separated list of roles provided in the end is in the alphabetical order.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>