mysql - Count number of rows where Extract Value found a match -


100,000 rows in table contains column stores large xml block, need check if there xml tag filled data in column, lets column called test_request , xml tag named 'd'. want make sure value inside 'd' doesn't contain newline /n within xml tag. every row has match want add 1 overall count. here query far.

select extractvalue( uncompress(`test__request` ) ,  count('/a/b/c/d') )  testtable16  `test_created` >  '2014-08-16 10:00:00' ,  `test_created` <=  '2014-08-16 10:10:00' ,  `test_client` =  'test2' ,  `test_user` =  'testuser2' , uncompress(  `test__request` )  '%<testid>test</testid>%' limit 0 , 30 

it doesn't work though returns 100,000 rows cant sift through. , not sure how isnt newline check.

if return rows count, should move count where clause.

my xpath little rusty, believe can use predicate contains function:

select * testtable16  `test_created` >  '2014-08-16 10:00:00' ,  `test_created` <=  '2014-08-16 10:10:00' ,  `test_client` =  'test2' ,  `test_user` =  'testuser2' , uncompress(`test__request`)  '%<testid>test</testid>%' , extractvalue(        uncompress(`test__request`),         'count(/a/b/c/d[contains(text(),"\n")])'     ) > 0 limit 0 , 30 

if want return count of rows have @ least 1 match use select count(*) ...

if want total of node counts use:

select sum(extractvalue(           uncompress(`test__request`),            'count(/a/b/c/d[contains(text(),"\n")])'        )) testtable16  `test_created` >  '2014-08-16 10:00:00' ,  `test_created` <=  '2014-08-16 10:10:00' ,  `test_client` =  'test2' ,  `test_user` =  'testuser2' , uncompress(`test__request`) '%<testid>test</testid>%' 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -