I am using SQL.
Here is an example of my table: (There are actually thousands of rows like these, with varying course numbers.)
Course No | Meeting Day | Course Name | Instructor
123 | M | English | Smith
123 | W | English | Smith
123 | F | English | Smith
I need to concatenate these rows into one like:
123 | MWF | English | Smith
Is this possible? :)
TIA.
Upvotes: 0
Views: 1477
Reputation: 26100
In MySQL, you can use the GROUP_CONCAT
function with a GROUP BY
:
SELECT
course_no,
GROUP_CONCAT(DISTINCT meeting_day SEPARATOR '') days,
course_name,
instructor
FROM
courses
GROUP BY
course_no, course_name, instructor
Upvotes: 2