[英]Select Statement using Mysql
I am new to using databases, 我是新手使用数据库,
I have a table ( easy_drinks ) 我有一张桌子(easy_drinks)
+------------+-------------+---------+
| Drink_name | main | amount1 |
+------------+-------------+---------+
| Blackthorn | Blackthorn | 1.5 |
| BlueMoon | soda | 1.5 |
| OhMyGosh | peachnectar | 1 |
+------------+-------------+---------+
I have a Query 我有一个查询
SELECT Drink_name
FROM easy_drinks
WHERE main > 'soda'
;
It is giving results as Blakcthorn 它正在以Blakcthorn的形式给出结果
Can you please explain how string comparison occurs between ie with main and 'soda' ? 你能否解释一下ie与main和'soda'之间如何进行字符串比较?
It compairs the strings using the underlying values of the collation
the fields use in a lexiographic order. 它使用字段在lexiographic顺序中使用的
collation
的基础值来对字符串进行比较。 That means that capitals are "bigger" (before) non capitals. 这意味着资本在非首都之前“更大”(之前)。
Note: If both strings use a different collation, one will be converted. 注意:如果两个字符串使用不同的排序规则,则会转换一个字符串。
If you do not prefer to distinguish capitals and non capitals use something like 如果你不喜欢区分大写字母和非大写字母,请使用类似的东西
SELECT Drink_name
FROM easy_drinks
WHERE LOWER(main) > 'soda'
;
You can also use the strcmp
function (see here ). 您还可以使用
strcmp
函数(请参阅此处 )。
SELECT Drink_name
FROM easy_drinks
WHERE strcmp(LOWER(main),'soda') = 1
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.