且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在where子句中使用不同的like运算符,

更新时间:2023-01-20 07:55:34

这取决于你要做什么:第二个我尝试过的东西语法根本不起作用(并且没有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).