首页 > 解决方案 > 检查记录是否存在返回错误结果

问题描述

我有一个名为的表match_lineup_substitute,其中包含以下记录:

player_substitute_id | player_substituted_id | match_id |
       90930                   NULL             2807486

我想检查记录是否存在,所以我写了这个查询:

SELECT COUNT(*) FROM `match_lineup_substitute` 
                WHERE match_id = 2807486 AND 
                player_substitute_id = 90930 AND player_substituted_id = null         

这将返回:0

发生了什么?

标签: mysqlsql

解决方案


要检查null值,请使用is

... and player_substituted_id IS NULL

文档


推荐阅读