返回group_concat数据作为数组 [英] return group_concat data as array
本文介绍了返回group_concat数据作为数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想返回使用group_concat作为数据数组从db中检索到的值.是否可以在mysql查询中执行此操作?还是我需要将数据分解成一个数组?
I want to return values I retrieve from the db using group_concat as an array of data. Is it possible to do this in the mysql query? Or do I need to explode the data into an array?
GROUP_CONCAT(sh.hold_id) as holds
返回此
[holds] => 3,4
我希望它返回:
[holds] => array(3,4)
推荐答案
正如我在评论中所说:您需要使用以下php代码将数据分解为数组:
As I said in my comment: you need to explode the data into an array, using php code like this:
$holds = explode(',', $holds);
因为mysql没有数据的数组类型的概念.
because mysql has no concept of array-type for data.
这篇关于返回group_concat数据作为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文