I want to search for a text in the table column which has got <em>
tag without any anchor tags inside.
From the following two:
<em> some text </em>
<em> some text <a>anchor tag</a></em>
I want '<em> some text </em>
' as the output. Second one has got anchor tag within <em>
tag, which I want to exclude. Could anyone
please help.
WHERE YourColumn LIKE '%<em>%</em>%'
AND YourColumn NOT LIKE '%<em>%<%</em>%'
however, this would, wrongly??, catch
<em> some text <em>further emphasized</em></em>
My LIKE test is assuming that EM and /EM are not necessarily the first/last elements in the column. If you only want to match first/last then remote the leading & trails "%"
P.S. this is all a bit "wobbly". I am only looking for an "<" within the EM ... /EM which of course might not be a TAG, If you want to do a "proper job" you'll need something that parses the content ... SQL's RegEx isn't up to that job.
or
where len(col+'#')-len(replace(replace(col1+'#','<em>',''),'</em>',''))=9