mysql only compares first numerical part of string to int column in where -
this more "why" or "any pointers documentations" question.
today realised comparison in clause takes first numerical part of string if compared int column. (my own conclusion)
for example:
select * companies c id = '817m5'
will still return companies id = 817.
it make sense i'm failing find documented anywhere see if conclusion correct , if there additional things know exact behaviour. where
, int type, comparison documentation? where? how called?
thanks!
this comparison:
where id = '817m5'
and id
integer.
so, mysql has compare integer string. well, can't directly. either has convert string number or number string. mysql converts string number, converting leading numeric characters. so, '817m5'
becomes 817
.
here exact quote:
to cast string numeric value in numeric context, not have other use string value though number:
mysql> select 1+'1'; -> 2
Comments
Post a Comment