我在mysql查询中出错(错误代码:1054
'字段列表'中的未知列'p.post_id')
邮局表中显示post_id
任何人都可以帮助我解决这个问题
SELECT u.iname , p.post_id,p.file_path
FROM users u
INNER JOIN likes l
ON u.user_id=l.user_id
INNER JOIN notify n
ON p.post_id=n.post_id
INNER JOIN post p
ON p.user_id=u.user_id
WHERE u.user_id=3 AND n.notify=1
答案 0 :(得分:2)
表没有以正确的顺序连接,你不能在第二个连接中引用post_id,因为posts表尚未连接。
SELECT u.iname, p.post_id, p.file_path
FROM users u
INNER JOIN likes l ON u.user_id = l.user_id
INNER JOIN post p ON u.user_id p.user_id
INNER JOIN notify n ON p.post_id = n.post_id
WHERE u.user_id = 3 AND n.notify = 1