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-692ae29b8deff392415063/]  

7 years ago

SELECT Null

[crayon-692ae29b8dff1641354119/]  

7 years ago

ALTER Column SET NOT NULL – pgSQL

[crayon-692ae29b8e0a7636117068/]  

7 years ago

ADD new Column – pgSQL

[crayon-692ae29b8e147248416328/] [crayon-692ae29b8e14a677979702/]  

7 years ago