简体   繁体   English

使用通配符

[英]Using wildcards

Can anyone help me out with this- 谁能帮我这个忙-

There is a column in the database as "TEXT". 数据库中有一列为“ TEXT”。 This column hold some string value. 该列包含一些字符串值。 I want to search any row that is having '%' in this column . 我想搜索此列中具有“%”的任何行。

For eg how will i search for a row having value 'Vivek%123' in the column TEXT 例如,我将如何在“ TEXT”列中搜索值为“ Vivek%123”的行

您必须转义%字符

WHERE COL1 LIKE 'Vivek@%123' ESCAPE '@' ;

In sql there is something known as an escape character, basically if you use this character it will be ignored and the character right behind it will be used as a literal instead of a wildcard in the case of % 在sql中,有一个称为转义字符的东西,基本上,如果使用此字符,它将被忽略,并且在%的情况下,它后面的字符将用作文字,而不是通配符。

WHERE Text LIKE '%!%%'
ESCAPE '!' 

The above sql statement will allow you to search for any string containing a percentage character '%' so it could find anything in the format of 上面的sql语句将允许您搜索任何包含百分比字符'%'的字符串,以便它可以找到格式为

string%string 字符串%字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM