Skip to content Skip to sidebar Skip to footer

Join Two Rows Which Have Same Value In Two Column

This is printscreen image of my table. I have a MySQL table named 'table'. When I wrote 'SELECT * FROM table' in the while loop, I want to get one time same values of 'fikraNo' an

Solution 1:

You need an aggregate function to concatenate together the iceriks, and if you also want to show the minimum id, you also need an aggregate function to get that.

This should do the job:

SELECT MIN(id),
       fikraNo,
       maddeNo,
       GROUP_CONCAT(icerik ORDER BY id DESC SEPARATOR ' ')
FROM `table`
GROUP BY fikraNo, maddeNo

Demonstration here: http://sqlfiddle.com/#!2/ad7c93/1


Post a Comment for "Join Two Rows Which Have Same Value In Two Column"