Kevin
Kevin

Reputation: 6831

A question on contains() format in XQuery

my XQuery worked perferctly, but I've always used exact match, like:

concat(' and title ="',$title,'"')

However, this is not going to work in real world, since we need to change the exact match to contain.

In this case, the title is an XML element, $title is the variable defined in the XQuery, what we want is to do not just use equal sign but test whether the title contains the substring $title.

I've played around with the syntax but still failed, could anyone help me on getting the right syntax for changing the "=" to the contains?

Thanks in advance.

Upvotes: 0

Views: 251

Answers (2)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243529

Use:

concat(' and title[contains(.,"', $title, '")]')

Upvotes: 1

LarsH
LarsH

Reputation: 28004

and title = $title

should become

and contains(title, $title)

But I don't understand really what you're trying to do with concat. Are you trying to generate an XQuery expression using XQuery? In that case you could change

concat(' and title = "', $title, '"')

to

concat(' and contains(title, "', $title, '")')

Upvotes: 1

Related Questions