I have an XML type column called "tags".
In this I store a collection, for example:
<ArrayOfString> <string>personal</string> <string>travel</string> <string>gadgets</string> <string>parenting</string> </ArrayOfString>
I want to select all rows that have one of the values I'm looking for: for example, I want to select all rows in a table with the tag "travel".
I know this works if I know the index of the value I'm looking for:
select * from posts where tags.value('(/ArrayOfString/string)[1]', 'nvarchar(1000)') = 'travel'
but this query only works if the "travel" tag is the second element in the nodes. How to check if any value exists regardless of its position?
ashwnacharya
source share