mysql - Query always return all the data -
why mysql query returns column data table?:
select column table column = "+"
the column type varchar.
ok, after clarifying query, it's little clearer has happened. in mysql, +
numeric operator only, not concatenation operator. non-numeric strings cast zero, if attempt "add" 2 empty strings (pairs of single quotes), selecting 0 + 0
.
mysql> select 1 + 1, '' + '', '1abc' + 1; +-------+---------+------------+ | 1 + 1 | '' + '' | '1abc' + 1 | +-------+---------+------------+ | 2 | 0 | 2 | +-------+---------+------------+ 1 row in set, 1 warning (0.00 sec)
and since non-numeric strings cast zero, non-numeric string in column match condition
where column = 0
example comparing 0 numeric , non-numeric string:
mysql> select 'abcd' = 0, '1234' = 0; +------------+------------+ | 'abcd' = 0 | '1234' = 0 | +------------+------------+ | 1 | 0 | +------------+------------+ 1 row in set, 1 warning (0.00 sec)
Comments
Post a Comment