Home > database >  SQL string comparison - why is this true?
SQL string comparison - why is this true?

Time:10-21

I'm trying to figure out why the following is false in SQL

'20001' >= '20000' AND '20001' < '2000:'

The character ':' has a higher value in the ASCII table than '1' so I expected the condition to be true, is that not how it works?

CodePudding user response:

It has to do with the Collation: Collations also determine the rules that sort and compare data(from here) i.e. your database is sorting (choosing what is > or < ) based on your defined collation, rather than based on ASCII values)

  • Related