Need Help with a MySQL Query

Need Help with a MySQL Query
0

#1

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!


#2

SELECT fullname from TABLE where department = “Computer Science”


#3

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!


#4

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


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

This is one of the queries that I have tried…


#7

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


#8

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