I'm attempting to filter out books with 'Romance' under Subject without using a WHERE filter.

<book>
  <bk_id>402</bk_id>
  <bk_title>Adult Book</bk_title>
  <bk_subject>Romance</bk_subject>
  <bk_price>$35.99</bk_price>
  <bk_authors>
    <author>Dodgson</author>
  </bk_authors>
</book>

SELECT datax.value ('(//book[book_subj[1] eq "Romance"])', 'varchar(12)') AS RomanceBooks FROM xml_book

XQuery [xml_book.datax.value()]: Cannot implicitly atomize or apply 'fn:data()' to complex content elements, found type 'book' within inferred type 'element(book,#anonymous) *'.

This error is preventing me from running this query. My question is, is this possible to do so without using a Where filter?

有帮助吗?

解决方案

It is not possible to limit the rows returned using the column list of a SQL query.

If you want a filter on rows in the table xml_books you need a where clause, a join or a cross apply.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top