如何在where子句中使用不同的like运算符, [英] How to use different like operator in where clause,

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

问题描述

我在where子句中使用like运算符编写查询。我需要在where子句中使用不同的运算符。



假设UniversityName Column包含一个字符串'

I am writing a query with like operator in where clause. i need different like operator in where clause.

suppose UniversityName Column contain a string '

UU3-UU8-UU14-UU18-UU23-UU24-UU45-UU74

'



i不想使用OR运算符。所以我想使用In Operator。但它不起作用。



我尝试过:



'

i don't want to use OR operator. so i want to use In Operator. but it not working.

What I have tried:

Select * From MasterCustomer where UniversityName Like'%UU1%'







Select * From MasterCustomer where UniversityName In (Like'UU1', Like'UU1-%', Like'%-UU1', Like'%-UU1-%')

推荐答案

这取决于你要做什么:第二个我尝试过的东西语法根本不起作用(并且没有LIKE序列符合你的例子)。



但第一个:

It depends what you are trying to do: the second "what I have tried" syntax will not work at all (and none of the LIKE sequences would match your example).

But the first one:
...WHERE UniversityName LIKE '%UU1%'



应该有效,因为它会多次匹配你的例子:UU14和UU18。 %是一个通配符,表示任意数量的任何字符,类似于Windows文件名中的*,因此'%UU1%匹配任何位置包含UU1的任何输入字符串。



我怀疑你需要再看看你的数据,因为我怀疑 UniversityName 列不包含UU3-UU8-UU14 -UU18-UU23-UU24-UU45-UU74(或其内容的列名完全错误)。


should work, as it will match your example several times: UU14 and UU18. The "%" is a wildcard, meaning "any number of any characters", similar to the "*" in windows filenames, so '%UU1% matches any input string that contains UU1 in any location.

I suspect that you need to take another look at your data, as I suspect the UniversityName column does not contain "UU3-UU8-UU14-UU18-UU23-UU24-UU45-UU74" (or is has completely the wrong column name for the content it does have).


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

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