id | value1 | value2 | value3 |
1 | 1 | 1 | 1 |
2 | 32 | 2 | 1 |
4 | 1 | 3 | 1 |
这时要 查出结果为 1,2,4 sql语句
select GROUP_CONCAT(id) as ids from databases limit 0,1
结果为string 1,2,4
SELECT group_concat(id separator ';') as a FROM `cmf_portal_category` WHERE ( parent_id = 37 ) limit 0,1
//tp5写法:
$cate_drivers_infos = Db::name('portal_category')->field("group_concat(id separator ';') as ids")->where('parent_id = 37')->find()['ids'];
//结果集
结果为string 1;2;4;5