KItis
KItis

Reputation: 5626

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

Upvotes: 0

Views: 62

Answers (1)

A.B.Cade
A.B.Cade

Reputation: 16905

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

Upvotes: 2

Related Questions