混淆了mysql查询空白值

时间:2015-12-02 12:02:05

标签: mysql

我发现了mysql的现象,见下文

insert into t(phone) select '12345   ';#tail with 3 white spaces
insert into t(phone) select '12345';
select * from t where phone = '12345'; #all can query out
+----------+
| phone    |
+----------+
| 12345    |
| 12345    |
+----------+
select phone, length(phone) from t where phone = '12345';
+----------+---------------+
| phone    | length(phone) |
+----------+---------------+
| 12345    |             8 |
| 12345    |             5 |
+----------+---------------+
select version();
+-----------------------------+
| version()                   |
+-----------------------------+
| 5.6.27-0ubuntu0.14.04.1-log |
+-----------------------------+

即使你查询没有明确的空白值仍然可以获得空白值。 那么为什么呢?这是一个错误吗?

0 个答案:

没有答案