从员工表中获取所有员工详细信息,他们的表格“ first_name”从' ap&#x27之间的任何单个字符开始
SELECT
*
FROM
employees
WHERE
first_name LIKE 'A%'
OR first_name LIKE 'B%'
OR first_name LIKE 'C%'
OR first_name LIKE 'D%'
ORDER BY
first_name;
是否有任何新方法可以重写SQL查询以从A到P找到First_name
SELECT
*
FROM
employees
WHERE
first_name LIKE 'A%'
OR first_name LIKE 'B%'
OR first_name LIKE 'C%'
OR first_name LIKE 'D%'
ORDER BY
first_name;
is there any new way to rewrite the SQL Query to find the first_name starting from A to P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
:regexp_like
正则分解:
Use
regexp_like
:The regex breakdown:
^
means "start of text"[a-p]
means "any character in the range à to p inclusive"i
flag means "ignore case"不是只是
Isn't that just
使用
substr
提取第一个字符,然后比较:或您可以使用:
(将在
first_name
中使用索引,而第一个查询将不使用索引,而是需要基于函数的索引substr(first_name,1,1)
。)Use
SUBSTR
to extract the first character and then compare that:or you could use:
(Which would use an index on
first_name
, whereas the first query would not use the index and, instead, would need a function-based index onSUBSTR(first_name, 1, 1)
.)