简体   繁体   中英

SQL : How to search for a text field

I have table where one column of it holds the content of a xml file. Among these xml files, some contains text HASH_VALUE. i want to find out rows which are having xml files with the text HASH_VALUE. i tried to use like(%HASH_VALUE%) but this does not retrieve any row

could anybody explain me how to do this.

thanks in advance for any help

Here are two ways of doing this:

One uses xml:

select id, xml_col 
from t 
where xmlelement(r, xmltype(xml_col)).extract('//HASH_VALUE') is not null;

The other is your way:

select id, xml_col 
from t 
where xml_col like '%HASH_VALUE%';

Here is a sqlfiddle demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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