简体   繁体   中英

MySQL string comparison,greater than or less than, in which circumstances?

I am a little bit confused about string comparison in MySQL.

I want to know that if two string will be compared then how we know that by which circumstances MySQL is comparing two string. I will clear my question in parenthesis

(if condition is given, "First Name is equal to or greater than King" then what is the answer of this condition and how we know that this is the answer of this question).

Please clear my confusion.

See the example that explains better than words

CREATE TABLE test ( `value` VARCHAR(10) ); INSERT INTO test (`value`) VALUES ('KINe'), ('KINF'), ('king'), ('kinh'), ('kinga'), ('king0');
\n \n\n \n
SELECT value FROM test WHERE value >= 'king'
\n|  value |\n|  :---- | \n|  king |\n|  kinh |\n|  kinga |\n|  king0 |\n

db<>fiddle here

You can have a look at the ascii table for better understanding what is bigger then g

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM