sql problem

A, mybatis dynamic statements, comparative field problems

<if test=' s=="" '>
<if test=" s==''.toString()">

Two, MySQL string comparison issues

Problem Description:

The SELECT 2> 12 is; # result is 0 ( to false) 
the SELECT '2'> '12 is'; # results . 1 ( to true)

Just the type of change, but the result is the opposite, because the string is followed by character comparison, and the number is in accordance with the size of a direct comparison.

In alphabetical order to compare means: for example, the above '2' and '12' will first compare the size of the characters '2' and '1', if not equal, the outcome immediately, or continue to the next comparison until you get so far without result or may continue to compare, so you get the seemingly absurd 1 (true).

Conclusion: The original numbers and non-numeric string for the mixing, when making the size comparison, if the two strings of equal length, then two strings of characters will be compared to an identical position, if the comparison character is a number, a direct comparison, If the non-numeric characters it would be converted to ascii code comparison, if the size of the points already in a position, then it will not compare.

solution

cast (): standard syntax cast (value as type)

# Is converted to an integer (value interval 
[- 9223372036854775808 ~ 9223372036854775807])
Cast ( '12 is' the AS the SIGNED)
# or converted to an unsigned integer (value interval [ 0 ~ 18446744073709551615]) Cast ( '12 is' the AS UNSIGNED)

convert (): standard syntax convert (value, type)

  • # Convert integer Convert ( '12 is', the SIGNED) 
    # or converted to an unsigned integer Convert ( '12 is', UNSIGNED)

Direct string +0

select '123'+0

But the value is greater than the UNSIGNEDmaximum value of the type, use scientific notation, precision errors

Guess you like

Origin www.cnblogs.com/kobe24vs23/p/11592452.html