SQLite合并重复项 [英] SQLite merge duplicates
本文介绍了SQLite合并重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个SQLite表,其中有些行仅在一列中有所不同.我想用分隔符(本例中的换行符)合并此列中的条目.
I have a SQLite table, in which there are some Rows which differ in just one column. I want to merge the entrys in this Column with a seperator (line break in my case).
所以,这个:
| id | block | description|
------------------------------
| 1 | a | foo |
| 1 | a | bar |
| 3 | b | cat |
| 4 | c | mouse |
------------------------------
应该变成这个:
| id | block | description|
------------------------------
| 1 | a | foo \r\n bar|
| 3 | b | cat |
| 4 | c | mouse |
------------------------------
我什至不知道要搜索的内容(而不是合并",但是我找不到适合我的应用程序的任何内容),因此任何输入都会受到赞赏.
I don't even have an Idea what to search for (instead of "merge", but I couldn't find anything suitable for my application), so any Input would be appreciated.
简
推荐答案
我认为您正在寻找 group_concat()
:
I think you are looking for group_concat()
:
select id, block, group_concat(description, ' \r\n ')
from t
group by id, block;
这篇关于SQLite合并重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文