1

I have a table that has a list of events. I would like to join the unit values from multiple rows into one column for display purposes based on a unique value, "incident".

Current data:

Date Time Incident Unit
1/1  1200  1234    101
1/1  1200  1234    102

How I would like to display it:

Date Time Incident Unit
1/1  1200  1234    101, 102

I am using mysql/php.

Thanks!

2

2 Answers 2

3

Try this query:

SELECT `date`, `time`, `incident`, group_concat(`unit`) 
from table group by `incident`
Sign up to request clarification or add additional context in comments.

Comments

0

Use this query

SELECT date, time, incident, GROUP_CONCAT(unit SEPARATOR ", ") AS unit FROM table GROUP_BY incident

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.