我正在努力创建一个像应用程序一样的用户可以发送和接收图片的应用程序。我用来获取所有发送和接收声音列表的mysql:
SELECT *,
GROUP_CONCAT(picchats.picID) AS picID
FROM pics
JOIN picchats
ON pics.picID = picchats.picID
INNER JOIN users
ON picchats.senderID = users.id
OR picchats.recieverID = users.id
WHERE picchats.senderID = $UserID
OR picchats.recieverID = $UserID
GROUP BY pics.id
ORDER BY pics.id DESC
问题是它只能从users表中检索发件人名称,而不是从接收者名称中检索。问题似乎在于INNER Join的OR。有什么建议?
示例数据:
数组1 打开= 1; creatorID = 1; id = 1; path =“pics / 9DZZ6.jpg”; recieverID = 8; senderID = 1; picID =“9825,9825”; username = dshaffer ;
阵列2
打开= 1;
creatorID = 8;
id = 1;
path =“pics / 1VDQ1.jpg”;
recieverID = 1;
senderID = 8;
picID =“2043,2043”;
username = dshaffer ;
正在打印的所有数据都是正确的,除了用户名,对于第二个数组,用户名应该不同(因为creatorID不同