一列的DISTINCT值,但是我还需要与之关联的其余数据

So all data is in one table i need to be able to get the main column and all its associated in a list, it will be better to give an example

Course....    | Subject...... |  
Maths...... . |  division.....|   
Maths.......  |  bidmass......|    
PE............| Gym work......|

So what i want it to return is:

**Maths**

Division


Bidmass

**PE**

Gym Work

So basically i want the course to be its title and any row associated with it at the momment i Have:

SELECT Course, CONCAT(Course, ' ', Subject) AS ColumnZ 
FROM products
GROUP BY Subject
ORDER BY COurse ASC"

the group by Subject was used as there duplicates of subjects

How do I grab all the courses with a list of subjects so i can output this in a UL format

don't group by subject, what if the same subject was in a different course, you would lose one. group by Course, then Subject like this.

SELECT Course, Subject, CONCAT(Course, ' ', Subject) AS ColumnZ 
FROM products
GROUP BY Course, Subject
ORDER BY Course, Subject

now loop through the results, put course into a variable $prev_course, and if the $row[course] changes from the previous course then you know to output the next course header $row[Course] otherwise just output the $row[Subject]