I google search 'sql like operator on integer', all tell me to use
where cast ( int_field as text ) like '0.%'
Warning: reality is opposite position!!!
why I can use 'like' operator on integer, decimal, directly, without cast?
here is my mysql example:
another example:
integer type
CodePudding user response:
This is handled by an implicit type conversion in MySQL.
When you use a numeric type in a string context, i.e. comparing it to a string, then the numeric is implicitly converted to a string, then the comparison is evaluated. You don't need to use CAST()
first.
This is documented for MySQL here:
first paragraph again... "If any one of the arguments isn't of character string data type, the SQL Server Database Engine converts it to character string data type, if it's possible