Using GROUP_CONCAT on subquery in MySQL

前端 未结 5 1707
我在风中等你
我在风中等你 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:30

    I think you may have the "userid = itemid" wrong, shouldn't it be like this:

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

提交回复
热议问题