Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
oraclesql中的搜索字符串_Sql_Oracle12c - Fatal编程技术网

oraclesql中的搜索字符串

oraclesql中的搜索字符串,sql,oracle12c,Sql,Oracle12c,问题是如何在employees表中搜索以字母“G”开头的名称。我使用的是Oracle 12c版本 我找到了答案: select * from employees where first_name >= 'G' and first_name < 'H'; 选择* 来自员工 其中first_name>='G' 和名字

问题是如何在employees表中搜索以字母“G”开头的名称。我使用的是Oracle 12c版本

我找到了答案:

select * 
from employees 
where first_name >= 'G' 
  and first_name < 'H';
选择*
来自员工
其中first_name>='G'
和名字<'H';

你能帮我理解这背后的逻辑吗。

除了注释的内容之外,你还可以使用
LIKE
操作符,因为你最终会尝试从
G
开始获取所有
名字

select * from employees where first_name like 'G%'

除了要注释的内容外,您还可以使用
LIKE
操作符,因为您最终将尝试获取所有
名字
G

select * from employees where first_name like 'G%'

您还可以使用regexp搜索以G开头的姓名,如下所示:

select * from employees 
WHERE REGEXP_LIKE (first_name, '^G','i');

此处参数“i”将忽略名称的大小写。

您也可以使用regexp搜索以G开头的名称,如下所示:

select * from employees 
WHERE REGEXP_LIKE (first_name, '^G','i');

这里参数“i”将忽略名称的大小写。

它们只是字符串比较,这意味着
'g'
是真的,因为
g
在字母表中位于
h
之前。字符串的长度无关紧要。在锁步中比较字符,一旦出现不匹配,就会得到比较结果。它们只是字符串比较,这意味着
'g'<'harrison'
是真的,因为
g
在字母表中位于
h
之前。字符串的长度无关紧要。字符在锁步中进行比较,一旦出现不匹配,就会得到比较结果。谢谢Marc&RahulThanks Marc&Rahul