在SQL表达式中使用通配符

编程入门 行业动态 更新时间:2024-10-12 18:21:05
本文介绍了在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 ...): sqlserver2000.databases.aspfaq/how-do-i-search-for-special-characters-eg-in-sql-server.html maybe this link is helpful (how to escape the _ char ...): sqlserver2000.databases.aspfaq/how-do-i-search-for-special-characters-e-g-in-sql-server.html

更多推荐

在SQL表达式中使用通配符

本文发布于:2023-11-22 01:31:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615450.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通配符   表达式   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!