1、mysql语句
格式化时间戳
select id,name,FROM_UNIXTIME(time,'%Y-%m-%d %H:%i:%s') as addtime from testtable where totaltime != '';
//time是时间戳字段,查出来之后是格式化的数据 ,重命名为 addtime 注意:time是10位时间戳
显示结果
select id,name,UNIX_TIMESTAMP(time) as addtime from testtable1; //我的数据库存的time格式是这样的 :2019-02-27
Mysql将查询结果某个字段以逗号分隔,使用group_concat函数可以实现(配合group by使用)
示例:SELECT Id, GROUP_CONCAT(Name SEPARATOR ',') Names FROM some_table GROUP BY id