SELECT namaline, shift1 FROM semualine WHERE cektelatshift1 <> 'Ontime' UNION
SELECT namaline, shift2 FROM semualine WHERE cektelatshift2 <> 'Ontime' UNION
SELECT namaline, shift3 FROM semualine WHERE cektelatshift3 <> 'Ontime';
namaline | shift1 |
---|---|
Line 1 | Shift 1 |
Line 2 | Shift 1 |
Line 3 | Shift 1 |
Line 1 | Shift 2 |
Line 2 | Shift 2 |
Line 3 | Shift 2 |
Line 1 | Shift 3 |
Line 2 | Shift 3 |
I want to combine all this result into 1 cell
myexpectation is
1 cell |
---|
Line 1 Shift 1, Line 2 Shift 1, Line 3 Shift 1, Line 1 Shift 2, Line 1 Shift 1, Line 2 Shift 2, Line 1 Shift 3, Line 2 Shift 3 |
3
Answers
Thank for all the answer. Sorry, I'm still new here should show my DB and used english. I figure out the close answer.
To achieve the output format you are looking for the following needs to be done
In GROUP_CONCAT space is needed between columns to have the space in the output as well
The repeating pattern
shift1, cektelatshift1, shift2, cektelatshift2, ...
is a good indication of a table that would benefit from being normalized.Both of these queries provide a result similar to your example (cannot be the same as your example is inconsistent). They differ in whether it is the row or column which is concatenated first.