Mysql implicit type conversion principle and mysql implicit Principle
MySQL implicit type conversion principle:
-If either of the two parameters is NULL, the comparison result is NULL. The exception is that when two NULL values are compared, 1 is returned. No type conversion is required in both cases.
-Both parameters are strings and will be compared by strings without type conversion.
-Both parameters are integers, which are compared by integers without type conversion.
-When the hexadecimal value is compared with a non-numeric value, it is treated as a binary string. When compared with a number, it is processed according to the following rule.
-If one parameter is TIMESTAMP or DATETIME and the other parameter is a constant, the constant is converted to timestamp.
-One parameter is of the decimal type. If another parameter is of the decimal or Integer type, the integer is converted to a decimal type before comparison. If the other parameter is of the floating point type, converts decimal to a floating point number for comparison.
-In all other cases, the two parameters are converted to floating point numbers for comparison.
Note a security question: if the password type is string and the query condition is int 0, it will match.
Because the implicit conversion rules of MySQL are complex, it is easy to encounter unexpected problems depending on MySQL implicit conversion. MySQL implicit conversion itself is also very expensive for MySQL server performance, therefore, this is not recommended.
See blog: http://www.cnblogs.com/rollenholt/p/5442825.html