+-------+-----------+------------+
| id | sequence | text |
+-------+-----------+------------+
| 12345 | 01 | Hello, my |
| 12345 | 02 | name is CJ |
| 54321 | 01 | Good morn |
| 54321 | 02 | ing! Sup! |
+-------+-----------+------------+
我完全迷失了。这些行中有2条消息1)“你好,我的名字是CJ”和2)“早上好!Sup!”
如何通过ID和正确的顺序(序列)选择这两种消息?
所以结果将是
“你好,我的名字是CJ”
“早上好!Sup!”
答案 0 :(得分:1)
尝试 GROUP_CONCAT
SELECT id,GROUP_CONCAT(text SEPARATOR ' ')
FROM tableA
GROUP BY id;
答案 1 :(得分:0)
$scope.clicked = function(index){
let currentOption=$scope.Persons[index].show;
$scope.Persons.forEach(x=>x.show=false);
$scope.Persons[index].show=!currentOption;
}
答案 2 :(得分:0)
SELECT id,GROUP_CONCAT(text ORDER BY sequence SEPARATOR ' ') AS messages
FROM table1
GROUP BY id;
<强>输出强>
id messages
12345 Hello, my name is CJ
54321 Good morning! Sup!
<强>演示强>
GROUP_CONCAT()函数
MySQL GROUP_CONCAT()函数返回一个连接的字符串 来自组的非NULL值。
语法:
GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [,col_name ...]]
[SEPARATOR str_val])