这是我桌子的打印图像。
我有一个名为" table"的MySQL表。当我写下#34; SELECT * FROM table
"在while循环中,我希望得到一次相同的" fikraNo"和" maddeNo"。但如果fikraNo和maddeNo具有相同的价值," icerik"必须加入。
例如,当我想从表中获取所有值时,输出必须如下:
1 1 174 Lorem ipsum dolor sit amet, consectetur adipiscing...
2 2 174 1500'lerden beri kullanılan standart Lorem Ipsum...
3 3 174 Nullam mollis accumsan quam eget aliquet. Ut sit a...
4 1 135 Phasellus ac massa neque. Nunc blandit, nibh sit a...
5 2 135 Nulla id placerat odio. Fusce quis porttitor dui. ...
6 0 135 Vestibulum elit neque, ultrices ac consequat vitae...
7 1 134 Etiam dignissim, lacus sed faucibus auctor, felis ...
8 2 134 Vestibulum rhoncus ultricies arcu id feugiat. Null...
9 1 133 Donec sit amet nunc urna. Vivamus id dui velit, ac...
10 0 133 Maecenas aliquet pellentesque egestas. Vestibulum ...
11 0 109 armut dalda kız balkonda sallanır vay vay...
12 1 109 Duis consequat luctus rhoncus. Etiam ante lectus, ...
14 3 116 Lorem ipsum dolor sit amet, consectetur adipiscing...
15 0 2 This is the first item in the first field.
16 0 2 And this is the second item in second field.
你能帮助我吗,我该如何处理? 最好的问候。
答案 0 :(得分:2)
你需要一个聚合函数来连接icerik
,如果你还想显示最小id,你还需要一个聚合函数来实现它。
这应该做的工作:
SELECT MIN(id),
fikraNo,
maddeNo,
GROUP_CONCAT(icerik ORDER BY id DESC SEPARATOR ' ')
FROM `table`
GROUP BY fikraNo, maddeNo