Implicit automatic casting
suggest changeselect '123' * 2;
To make the multiplication with 2 MySQL automatically converts the string 123 into a number.
Return value:
246
Conversion reads digits from the left. If the string does not start with a number, the result is 0. A leading number is used and the rest of the string is ignored. In strict SQL mode, that ignored tail is a warning, not an error, for this expression.
select '123ABC' * 2
Return value:
246
select 'ABC123' * 2
Return value:
0
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents