How do MIN() and MAX() work on CHAR/VARCHAR strings in MySQL?

前端 未结 1 673
无人共我
无人共我 2021-01-04 13:26

I\'ve been playing with the world database (InnoDB) found here to gain more insight into MySQL.

I entered the following basic query:

SELECT COUNT(Nam         


        
相关标签:
1条回答
  • 2021-01-04 13:43

    MySQL string comparison, technically called collation, is locale-dependent. I suggest reading sections 10.1.1 on collation in general, 10.1.2 on collation in MySQL and 10.1.7 about collation issues. On http://collation-charts.org/ you can find out details about the individual collations, e.g. the one called latin1_general_ci (where _ci stands for case insensitive). The collation used when you call MAX and MIN should be the collation of the column in question, unless you specify a different collation using a formulation like MAX(Name COLLATE latin1_german2_ci).

    0 讨论(0)
提交回复
热议问题