如何在 Tuple Criteria MYSQL 中查询空值

How to query with null value in Tuple Criteria MYSQL

MYSQL查询:

select * from CLASS where (CLASS_ID, CLASS_NAME) = (1, "FIRST");

同样,我需要一个包含空值的元组,例如:

select * from CLASS where (CLASS_ID, CLASS_NAME) = (1, null);

但上面的空值查询在 mysql 中不起作用。

谁能帮我构造查询?

您无法使用比较运算符检查 NULL 值。您唯一的选择是使用 IS NULL.

所以你可以使用这样的东西:

(CLASS_ID, CLASS_NAME) = (1, "FIRST") OR (CLASS_ID = 1 AND CLASS_NAME IS NULL)