转:https://www.cnblogs.com/pcheng/p/5943156.html 温馨提醒:如果是多表查询,并且多个列使用了group_concat函数,其中有列用了排序,那么其他使用了函数的列也要用上排序,否则数据对应就有误啦。也就是说,如图上的使用了ORDER BY score DESC,那么其他使用了group_concat的列也要用上ORDER BY score DES...
insert into tb(seq, remark, createtime)
select 1, '说明1', to_date('20210101','yyyymmdd') from dual
union all
selec.
group
_
concat
函数
支持order by内部
排序
,例如:
# 按照id倒序拼接img
SELECT
GROUP
_
CONCAT
(img ORDER BY id DESC) FROM `thumb_table`;
https://mariadb.com/kb/en/
group
_
concat
/
使用insert命令在表
中
插入一些记录。
insert into DemoTable values('John','Smith');
insert into DemoTable1627 values('John','Doe');
insert into DemoTable162
groub by 是按照分组,默认不
排序
,groub后会选择默认
排序
的第一条进行返回。
如果分组前
排序
好的数据,取
排序
好的第一条数据
排序
,则需要加上limit ,进行强制
排序
。
SELECT m.*
from (
SELECT
if ( a.status = 'X002', a.fleet_na...
问题:数据库表
group
_
concat
_table有三个字段sex,score,school,现在java后台获取到的值为:
String sex = "0,1,2";
String score = "90,91,92";
String school = "a";
现在这三个字段的值要使用全匹配的方式插入到数据库
中
,即(0,90,a),(0,91,a),(0,92,a),(1,90,a