开发者

Wild card usage in XML

开发者 https://www.devze.com 2023-03-17 03:33 出处:网络
Need to filter all values containing B in 开发者_Go百科it from a DB2 table. (We use a tool that links XML with DB2)

Need to filter all values containing B in 开发者_Go百科it from a DB2 table. (We use a tool that links XML with DB2)

When i use "B*" it filters all values that has B as first character but when i give "*B*" it takes all values in database

<DESC VALUE ="*B*"> is not working

Is there any other way to prefix a wildcard character for searching elements.


I second Peter, use '%B%' see Wildcards in DB2 SQL

Ofcourse DB2 supports wildcard chars,

use % with LIKE clause in case to CHAR datatype

for eg.

SELECT * FROM your_table WHERE your_column LIKE '%1234%'

this will search matches for substring 1234 anywhere in the string & you will get result as desired: 1234 1234AB 1234ABCD AB1234CD

also

Basic SQL Coding for DB2 Universal Database for OS/390 (under 'Searching for String Patterns);

SQL has a powerful predicate that allows you to search for patterns in character string columns. This is the LIKE predicate. Suppose you want to generate a list of the candidates whose first name starts with the letter G.

SELECT fname,lname,wphone,hphone FROM candidate
WHERE fname LIKE 'G%' ORDER BY lname,fname

In this query, we use a wildcard character with the LIKE predicate. In SQL, the percent character (%) is a substitute for zero or more characters. The search string G% can be substituted with names like George, Gary, Ginger, and so on (since the percent character can substitute zero or more characters, the search string can also be a single letter G).

The percent character can be used any place in the search string. It also can be used as many times as you need it. The percent sign is not case-sensitive, so it can take the place of uppercase or lowercase letters. However, the constant characters included in your search string are case-sensitive.


select yourcolumn from yourtable where yourcolumn like '%B%'  

I have no idea about your XML-Tool but maybe this vould lead to a solution for you?

0

精彩评论

暂无评论...
验证码 换一张
取 消