比较运算符

编辑

用于比较一个或多个表达式的布尔运算符。

相等 (=)

编辑
SELECT last_name l FROM "test_emp" WHERE emp_no = 10000 LIMIT 5;

空值安全相等 (<=>)

编辑
SELECT 'elastic' <=> null AS "equals";

    equals
---------------
false
SELECT null <=> null AS "equals";

    equals
---------------
true

不等 (<> 或 !=)

编辑
SELECT last_name l FROM "test_emp" WHERE emp_no <> 10000 ORDER BY emp_no LIMIT 5;

比较 (<, <=, >, >=)

编辑
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 ORDER BY emp_no LIMIT 5;

BETWEEN

编辑
SELECT last_name l FROM "test_emp" WHERE emp_no BETWEEN 9990 AND 10003 ORDER BY emp_no;

IS NULL/IS NOT NULL

编辑
SELECT last_name l FROM "test_emp" WHERE emp_no IS NOT NULL AND gender IS NULL;

IN (<值1>, <值2>, ...)

编辑
SELECT last_name l FROM "test_emp" WHERE emp_no IN (10000, 10001, 10002, 999) ORDER BY emp_no LIMIT 5;