|
当有null的时候,又如下
root@localhost:test 10:59:08>select * from test_char;
+--------+
| name |
+--------+
| test-1 |
| test0 |
| NULL |
| test2 |
| |
| test4 |
+--------+
6 rows in set (0.00 sec)
root@localhost:test 10:59:23>select count(name='test' or null) as yyy from test_char;
+-----+
| yyy |
+-----+
| 0 |
+-----+
1 row in set (0.00 sec)
root@localhost:test 10:59:31>explain extended select count(name='test' or null) as yyy from test_char;
+----+-------------+-----------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | test_char | ALL | NULL | NULL | NULL | NULL | 6 | |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------+
1 row in set, 1 warning (0.00 sec)
Note (Code 1003): select count(((`test`.`test_char`.`name` = _utf8'test') or NULL)) AS `yyy` from `test`.`test_char` |
|