我必须在两个名为" play"的连接表上使用相似的列,我想区分它们,但我得到了#34;未知栏' p.plays'在'字段列表'"。我做错了什么?
SELECT *,
p.plays AS pl,
m.plays AS mp,
COUNT(p.sid) frequency,
FROM music m
JOIN plays p
ON p.sid = m.sid
INNER JOIN users u
ON u.uid = m.uid
INNER JOIN downloads d
ON d.sid = m.sid
WHERE p.time > NOW() - INTERVAL 3 DAY
AND p.sid != ''
AND m.perms != 'c'
GROUP BY m.sid
ORDER BY frequency DESC
LIMIT 50
图像。
表:音乐
表:播放
感谢。
答案 0 :(得分:0)
根据您在编辑中提供的表架构。您在Plays
表格中没有plays
列,这就是为什么会出现此错误,请尝试删除此p.Plays
SELECT *,
m.plays AS mp,
COUNT(p.sid) frequency,
FROM music m
JOIN plays p
ON p.sid = m.sid
INNER JOIN users u
ON u.uid = m.uid
INNER JOIN downloads d
ON d.sid = m.sid
WHERE p.time > NOW() - INTERVAL 3 DAY
AND p.sid != ''
AND m.perms != 'c'
GROUP BY m.sid
ORDER BY frequency DESC
LIMIT 50