MySQL: GROUP_CONCAT with LEFT JOIN

前端 未结 3 1758
南笙
南笙 2020-11-29 21:06

I\'m experiencing a problem with MySQL\'s \"GROUP_CONCAT\" function. I will illustrate my problem using a simple help desk database:

CREATE TABLE Tickets (
          


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 21:49

    I think @Dylan Valade's comment is the simplest answer so I'm posting it as another answer: simply adding a GROUP BY Tickets.id to the OP's SELECT should fix the issue. It fixed my own issue.

    However, for databases that are not small the accepted answer, especially if there are any predicates on Tickets.id appears to not involve a total table scan and so while the previous paragraph returns the correct results it appears to be much less efficient in my case.

提交回复
热议问题