当我运行这个查询时,它显示从a,B和c开始first_name但是没有显示first_name从D开始为什么... [英] When I run this query, it's showing start first_name from a, B and c...but not showing first_name start from D why...

查看:73
本文介绍了当我运行这个查询时,它显示从a,B和c开始first_name但是没有显示first_name从D开始为什么...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

when I run this query, it's showing start First_Name from A,B and C...but not showing First_Name start from D why...





我尝试过:





What I have tried:

select * from Employee where First_Name between 'A' and 'D' 

推荐答案

引用:

当我运行这个查询时,它显示从a,B和c开始first_name但是没有显示first_name从D开始为什么...

When I run this query, it's showing start first_name from a, B and c...but not showing first_name start from D why...



因为' D anuthing'> 'D'

尝试


Because 'D anuthing' > 'D'
Try

select * from Employee where First_Name between 'A' and 'E'


因为它正在使用字符串比较。

当你比较字符串时,它们会逐个字符地进行比较,整个比较的结果来自一对中的第一个差异。

因此,当你将'A'与'Andrew'进行比较时,'A '较低,因为第一个区别是'A'在'Andrew'之前结束。当你到达'D'时,会发生同样的事情:'D'出现在以D开头的任何字符串之前。由于BETWEEN指定序列的结尾,因此没有以D开头但具有多个字母的名称将在该范围内。

使用SUBSTRING提取第一个字符,或使用' E'作为上限并添加一个特定的检查以消除只是'E'的名称
Because it's using string comparisons.
When you compare strings, they are compared character by character, and the result of the whole comparison comes from the first difference in a pair.
So when you compare 'A' with 'Andrew', 'A' is lower, because the first difference is that 'A' ends before 'Andrew'. When you get to 'D', the same thing happens: 'D' comes before any string starting with a "D". Since BETWEEN specifies the end of the sequence, no name that starts with a "D" but has more than one letter will be in the range.
Either use SUBSTRING to extract the first character, or use 'E' as the upper limit and add a specific check to eliminate names which are just 'E'


这篇关于当我运行这个查询时,它显示从a,B和c开始first_name但是没有显示first_name从D开始为什么...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆