Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 从select语句对Concat进行分组_Mysql - Fatal编程技术网

Mysql 从select语句对Concat进行分组

Mysql 从select语句对Concat进行分组,mysql,Mysql,我不确定我的方法是否可行,但我正在尝试对包含2个字段的select语句执行group_concat。我得到一个错误:子查询每次返回超过1行。有谁能帮我找到一个解决办法,或者更好的办法 select t.recnum, (select group_concat((select concat(b.origtests,'^', d.name) as testing from order_origtests b join profile c

我不确定我的方法是否可行,但我正在尝试对包含2个字段的select语句执行group_concat。我得到一个错误:子查询每次返回超过1行。有谁能帮我找到一个解决办法,或者更好的办法

select t.recnum, (select group_concat((select concat(b.origtests,'^', d.name) as testing
                from order_origtests b
                join profile c on c.code = b.origtests
                join department d on d.recnum = c.dept
               )))
            FROM order_ t

您不会将
SELECT
放入
GROUP\u CONCAT
中。应该是

select t.recnum, (
    select group_concat(concat(b.origtests,'^', d.name))
    from order_origtests b
    join profile c on c.code = b.origtests
    join department d on d.recnum = c.dept
    ) AS testing
FROM order_ t
请注意,您的子查询与
t
中的任何内容都不相关,因此对于每个
recnum
,您都会得到相同的
testing