Categories: Snippets

Concatenate multiple MySQL rows into one field

SELECT SC.StudentID, GROUP_CONCAT((SELECT C.CourseName FROM courses C WHERE C.CourseID=SC.CourseID) SEPARATOR ', ') FROM studentcourses SC GROUP BY SC.StudentID

 

Recent Posts

Generate Slug URL in MySQL

A slug is a short name using human-readable keywords to identify a web page. For…

7 years ago

How to use SQL LIKE condition with multiple values in PostgreSQL?

[crayon-68bd7124a4af7401122736/]  

7 years ago

SELECT Null

[crayon-68bd7124a4ce1739214045/]  

7 years ago

ALTER Column SET NOT NULL – pgSQL

[crayon-68bd7124a4f68600548175/]  

7 years ago

ADD new Column – pgSQL

[crayon-68bd7124a50af493377845/] [crayon-68bd7124a50b3426892918/]  

7 years ago