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…

6 years ago

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

[crayon-67a5b36943247499143033/]  

6 years ago

SELECT Null

[crayon-67a5b36943343958761004/]  

6 years ago

ALTER Column SET NOT NULL – pgSQL

[crayon-67a5b36943416468262871/]  

6 years ago

ADD new Column – pgSQL

[crayon-67a5b369434e0494729157/] [crayon-67a5b369434e5147930479/]  

6 years ago