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

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -