什么命令LIKE'[atoz:a]%'在SQL Server中意味着什么?

时间:2021-06-15 22:31:10

I've inherited a database and application from a project and I'm trying to debug a problem with a database query.

我从项目继承了数据库和应用程序,我正在尝试使用数据库查询调试问题。

There's a line in the query that reads:

查询中有一行内容如下:

WHERE property_title LIKE '[atoz:a]%' 

I'm struggling to understand what the atoz command is doing as I've never come across it before - I assumed it was stating that it would only allow characters in the title - but some of the titles contain symbols such as () or -

我正在努力理解atoz命令正在做什么,因为我之前从未遇到过它 - 我假设它说它只允许标题中的字符 - 但是一些标题包含符号,如()或 -

I've tried searching for it on Google but I must be using the wrong terminology as nothing is appearing. If someone could explain it to me, or point me to a resource that would be great!

我曾尝试在Google上搜索它,但我必须使用错误的术语,因为没有任何内容出现。如果有人可以向我解释,或者指向一个非常好的资源!

Thanks

2 个解决方案

#1


3  

This is just part of the LIKE operator of T-SQL:

这只是T-SQL的LIKE运算符的一部分:

[ ]
Any single character within the specified range ([a-f]) or set ([abcdef]).
WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and starting with any single character between C and P, for example Carsen, Larsen, Karsen, and so on. In range searches, the characters included in the range may vary depending on the sorting rules of the collation.

[]指定范围内的任何单个字符([a-f])或set([abcdef])。 WHERE au_lname LIKE'[C-P] arsen'找到以arsen结尾的作者姓氏,并以C和P之间的任何单个字符开头,例如Carsen,Larsen,Karsen等。在范围搜索中,范围中包含的字符可能会根据排序规则的排序规则而有所不同。

The exact expression you're seeing:

你看到的确切表达:

'[atoz:a]%'

basically means this:

基本上意味着:

  • First any single character that can be one of the following:
    • a, t, o, z, or :
    • a,t,o,z或:

  • 首先可以是以下任何一个字符:a,t,o,z或:

  • Then followed by anything (even nothing)
  • 然后是任何东西(甚至没有)

Note that atoz does not mean any character from a to z, it literally means the 4 characters a, t, o and z. To get any character from a to z you would use [a-z]. The second a in the expression is redundant, as [aa] means the same as [a].

请注意,atoz并不意味着从a到z的任何字符,它的字面意思是4个字符a,t,o和z。要从a到z获取任何字符,您将使用[a-z]。表达式中的第二个a是多余的,因为[aa]表示与[a]相同。

#2


4  

This is looking for property_title that starts with the letters "a", "t", "o", "z" and ":". The second "a" is redundant.

这是寻找以字母“a”,“t”,“o”,“z”和“:”开头的property_title。第二个“a”是多余的。

I would guess the intention is actually:

我猜其意图实际上是:

WHERE property_title LIKE '[a-z]%' 

which would specify that the property title starts with a letter (or a lower case letter, depending on the collation being used).

这将指定属性标题以字母开头(或小写字母,具体取决于使用的排序规则)。

#1


3  

This is just part of the LIKE operator of T-SQL:

这只是T-SQL的LIKE运算符的一部分:

[ ]
Any single character within the specified range ([a-f]) or set ([abcdef]).
WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and starting with any single character between C and P, for example Carsen, Larsen, Karsen, and so on. In range searches, the characters included in the range may vary depending on the sorting rules of the collation.

[]指定范围内的任何单个字符([a-f])或set([abcdef])。 WHERE au_lname LIKE'[C-P] arsen'找到以arsen结尾的作者姓氏,并以C和P之间的任何单个字符开头,例如Carsen,Larsen,Karsen等。在范围搜索中,范围中包含的字符可能会根据排序规则的排序规则而有所不同。

The exact expression you're seeing:

你看到的确切表达:

'[atoz:a]%'

basically means this:

基本上意味着:

  • First any single character that can be one of the following:
    • a, t, o, z, or :
    • a,t,o,z或:

  • 首先可以是以下任何一个字符:a,t,o,z或:

  • Then followed by anything (even nothing)
  • 然后是任何东西(甚至没有)

Note that atoz does not mean any character from a to z, it literally means the 4 characters a, t, o and z. To get any character from a to z you would use [a-z]. The second a in the expression is redundant, as [aa] means the same as [a].

请注意,atoz并不意味着从a到z的任何字符,它的字面意思是4个字符a,t,o和z。要从a到z获取任何字符,您将使用[a-z]。表达式中的第二个a是多余的,因为[aa]表示与[a]相同。

#2


4  

This is looking for property_title that starts with the letters "a", "t", "o", "z" and ":". The second "a" is redundant.

这是寻找以字母“a”,“t”,“o”,“z”和“:”开头的property_title。第二个“a”是多余的。

I would guess the intention is actually:

我猜其意图实际上是:

WHERE property_title LIKE '[a-z]%' 

which would specify that the property title starts with a letter (or a lower case letter, depending on the collation being used).

这将指定属性标题以字母开头(或小写字母,具体取决于使用的排序规则)。