1

i have mysql error Subquery returns more than 1 row on this query with GROUP_CONCAT. Why I gat this error and how i can solve this problem?

 select SQL_CALC_FOUND_ROWS s.url, 
        GROUP_CONCAT(
        (select name 
             from labels_data ld, 
                  labels l 
             where ld.id=l.site_id=s.id 
         limit 2),
        ', '),
 ... more valid sql code ...
 as labels from sites s

1 Answer 1

3

You need to put the group_concat into the subquery. The subquery is returning more than one row (at least normally). It has a limit 2.

  (select group_concat(name , ', ')
    from labels_data ld join
         labels l 
         on ld.id=l.site_id=s.id 
    limit 2
  )

I also recommend that you use proper ANSI join syntax.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 -- but is that JOIN syntax correct? ld.id=l.site_id=s.id? Here's a sample Fiddle moving it to the WHERE clause: sqlfiddle.com/#!2/8dd09/1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.