我有这个工作 MySQL 查询(它被剥离以仅显示相关行):
SELECT
c.id AS id_comment
, bl.id_user AS block
FROM comments AS c
LEFT JOIN user_blocked AS bl ON
(c.id_user = bl.id_user AND :uid = bl.id_user_blocked)
OR (c.id_user = bl.id_user_blocked AND :uid = bl.id_user)
WHERE (c.id_title = :idt)
有用!但我只想得到结果,block IS NULL
所以我在其中添加了一个新条件WHERE
:
SELECT
c.id AS id_comment
, bl.id_user AS block
FROM comments AS c
LEFT JOIN user_blocked AS bl ON
(c.id_user = bl.id_user AND :uid = bl.id_user_blocked)
OR (c.id_user = bl.id_user_blocked AND :uid = bl.id_user)
WHERE (c.id_title = :idt) AND (block IS NULL)
但我得到这个错误:
SQL ERROR: SQLSTATE[42S22]: Column not found: 1054
Unknown column 'block' in 'where clause'
为什么?我究竟做错了什么?