Using GROUP_CONCAT on subquery in MySQL

前端 未结 5 1714
我在风中等你
我在风中等你 2021-02-02 06:28

I have a MySQL query in which I want to include a list of ID\'s from another table. On the website, people are able to add certain items, and people can then add those items to

5条回答
  •  天涯浪人
    2021-02-02 06:31

    The purpose of GROUP_CONCAT is correct but the subquery is unnecessary and causing the problem. Try this instead:

    SELECT ITEMS.id,GROUP_CONCAT(FAVOURITES.UserId)
    FROM FAVOURITES INNER JOIN ITEMS ON ITEMS.Id = FAVOURITES.ItemId
    WHERE ITEMS.Id = $someid
    GROUP BY ITEMS.ID
    

提交回复
热议问题