如何使用通配符运算符 [英] How to get word using wildcard operator

查看:150
本文介绍了如何使用通配符运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  SELECT  *  FROM 人员
位置姓氏喜欢 '  [!bsp]%' 



在上面的示例中,它将显示姓氏以"b","s"和"p"以外的任何字符开头的所有记录.

但是我想检索所有姓氏是否仅以H字符开头的记录,但是根据上述查询,它必须从一个字符(``b'',``s''和``p''除外)开始. div class ="h2_lin">解决方案

您的问题不是很清楚,但是基于以下语句:我要检索姓氏仅以H字符开头的所有记录" ,尝试:

 选择 *  FROM 人员
位置姓氏喜欢 '  H%' 


使用此
first_name不像``%[bsp]''


根据SQL标准,以下命令对于通配符操作很有用.

%用替换个字符
_用代替恰好是一个字符
[^  | charlist] 任何单个字符 in  charlist 


SELECT * FROM Persons
WHERE LastName LIKE '[!bsp]%'



Here in the above example, it will display all records where last name starts any character except ''b'' and ''s'' and ''p''.

But I want to to retrieve all records where last name starts from only H character or not, but according to above query it must start from one character except ''b'' and ''s'' and ''p''.

解决方案

Your question is not very clear but based on this statement: "I want to to retrieve all records where last name starts from only H character", try:

SELECT * FROM Persons
WHERE LastName LIKE 'H%'


use this
first_name not like ''%[bsp]''


As per SQL standards, the below commands are useful for wildcard operation.

%   A substitute for zero or more characters
_   A substitute for exactly one character
[^ or | charlist]  Any single character in charlist


这篇关于如何使用通配符运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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