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…

5 years ago

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

[crayon-66373a7eea269501652045/]  

6 years ago

SELECT Null

[crayon-66373a7eea3ca699404059/]  

6 years ago

ALTER Column SET NOT NULL – pgSQL

[crayon-66373a7eea50a504167060/]  

6 years ago

ADD new Column – pgSQL

[crayon-66373a7eea641089904520/] [crayon-66373a7eea65b040879665/]  

6 years ago