2016-09-15 13 views
-1

私の方法が可能かどうかはわかりませんが、2つのフィールドを連結するselectステートメントでgroup_concatを実行しようとしています。私はエラーが発生します:サブクエリは毎回1行以上を返します。誰もが解決策、またはこれを回避する良い方法として私を助けることができます。グループSelectステートメントからのConcat

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 

答えて

0

あなたはGROUP_CONCATSELECTを入れないでください。それはあなたのサブクエリがtに何にも相関していない

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 

注意する必要がありますので、あなたはすべてのrecnumに同じtesting列を取得します。

関連する問題