我正在使用mysql(5.1.71)并且在桌子下面。
mysql> DESCRIBE test;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| foo | varchar(30) | YES | | NULL | |
| hoge | varchar(30) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM test;
+------+------+
| foo | hoge |
+------+------+
| aaa | 111 |
| bbb | xxx |
+------+------+
2 rows in set (0.00 sec)
我得到的结果低于查询结果,但为什么它显示第二行?
mysql> SELECT * FROM test WHERE foo=''*'' AND hoge=''*'';
+------+------+
| foo | hoge |
+------+------+
| bbb | xxx |
+------+------+
1 row in set (0.00 sec)
我猜''*''被解释为空字符串的乘法而且查询与SELECT * FROM test WHERE foo=0 AND hoge=0;
相同,但我仍然无法理解。