Need Help with a MySQL Query

Hello campers, :slightly_smiling_face:

I am finding difficulties to make a mysql query based on this idea:

Computer Science
-Dan Vick
-Harry Jones

Marketing
-John Doe

Business
-Leo Rodriguez

IT
-Tim Ben

Could someone help me?
Thank you!

SELECT fullname from TABLE where department = “Computer Science”

I don’t want to hardcode the department name, is there any other way that I can write the query without moving the department name in an other table?

(I don’t want for example ‘Computer Science’ to be repeated but I want the names to appear (if more than one) under the department name)

Thanks!

Show me what you’ve tried that hasn’t worked.

SELECT DISTINCT `department`, fullname FROM system GROUP BY department

This is one of the queries that I have tried…

Does this do what you want?
SELECT department, GROUP_CONCAT( fullname ) FROM system GROUP BY department

1 Like

Perfect, just learned about GROUP_CONCAT() function.
Thank you @spenguin