Php Mysql查询CONCAT更改输出
我有以下疑问:Php Mysql查询CONCAT更改输出,php,mysql,sql,concat,Php,Mysql,Sql,Concat,我有以下疑问: mysql> select (select m.delay from messages m order by message_id desc limit 1) as Delay, s.min_delay, s.max_delay from statistics s order by s.date_hour desc limit 1; +-------+-----------+-----------+ | Delay | min_delay | max_delay | +--
mysql> select (select m.delay from messages m order by message_id desc limit 1) as Delay, s.min_delay, s.max_delay from statistics s order by s.date_hour desc limit 1;
+-------+-----------+-----------+
| Delay | min_delay | max_delay |
+-------+-----------+-----------+
| 10 | 7.00 | 12.00 |
+-------+-----------+-----------+
1 row in set (0.00 sec)
这很好。但我需要得到以下格式的结果:
Delay=10 Min_Delay=7.00 Max_Delay=12.00
我可以用concat来做吗?通常,您会在应用层进行转换。但是,如果需要,可以在MySQL中使用
concat()
:
你是说每一排?或者你只想要一条这样的线?
select concat_ws(' ',
concat('Delay=', (select m.delay from messages m order by message_id desc limit 1)),
concat('Min_Delay=', s.min_delay),
concat('Max_Delay=', s.max_delay)
)
from statistics s
order by s.date_hour desc
limit 1