组合句子成为1个字符串

时间:2014-09-24 02:47:15

标签: php mysql

我在数据库中有一个表:

---------------------------------------
- id - fileid -        sentences      -
---------------------------------------
- 1 -     1   -   I want eat .        -
- 2 -     1   -   I wanna eat banan . -
- 3 -     2   -   I wanna eat apple . -
- 4 -     2   -   I wanna sleep .     -
---------------------------------------

我想收集句子取决于'fileid'。结果是:

I want eat .  I wanna eat banan .

I wanna eat apple . I wanna sleep .

如何做假设我不知道fileid?感谢

1 个答案:

答案 0 :(得分:2)

我想你只想要group_concat()

select group_concat(sentences order by id separator '')
from table t
group by fileid