我使用MySQL 5.5。我有一张桌子comment
。
当我进行此查询时:
select sum(case when comment.entity_id=1 and comment.entity_type=1 then 1 else 0 end) as result1;
我得到了
ERROR 1109 (42S02): Unknown table 'comment' in field list
这不应该发生,因为
select * from comment;
工作正常。
错误在哪里?
答案 0 :(得分:4)
您缺少FROM子句:
SELECT SUM(CASE WHEN entity_id = 1 AND entity_type = 1 THEN 1 ELSE 0 END) AS result1
FROM comment