在SQL表达式中使用通配符_ [英] Using WildCard character _ in sql expression

查看:281
本文介绍了在SQL表达式中使用通配符_的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的数据库中有以下文件名.
TestDocument _ 1 _ 0
TestDocument _证据
Test45

当我在DocumentName文本框中输入Test_时,首先将其转换为大写并发送给查询,并且查询具有以下表达式,该表达式将返回所有记录,而不应返回任何记录.
请告诉我以下表达式的变化.

UPPER(DOC.ORIGINAL_FILE_NAME),例如%TEST_%"

谢谢,
Umesh Tayade

Hi,

I have a following file names in my database.
TestDocument _ 1 _ 0
TestDocument _ Evidence
Test45

when i am entering the Test_ in the DocumentName textbox it is forst converted to uppercase and send to the query and query has following expression which returns all record where it shouldn''t return any record.
please tell me the changes in the following expression.

UPPER(DOC.ORIGINAL_FILE_NAME) like ''%TEST_%''

Thanks,
Umesh Tayade

推荐答案

在t-SQL中,下划线"_"也是通配符.虽然百分号%"接受任何数量的字符中的任何值,但下划线接受的恰好是一个字符中的任何值.
In t-SQL the underscore, "_", is also a wildcard character. While the percent sign, "%", accepts any values in any number of characters, the underscore accepts any value for exactly one character.


也许此链接有用(如何对_进行转义char ...):

http://sqlserver2000.databases.aspfaq.com/how-do-i-search-for-special-characters-eg-in-sql-server.html
maybe this link is helpful (how to escape the _ char ...):

http://sqlserver2000.databases.aspfaq.com/how-do-i-search-for-special-characters-e-g-in-sql-server.html


这篇关于在SQL表达式中使用通配符_的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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