【发布时间】:2025-12-02 14:05:01
【问题描述】:
我有一个存储这些文档的表。我想显示名字以 K 开头的作者的标题。我的讲师没有为我通过这个作业,怎么了?
SELECT XPATH('/bookstore/book[author = ".*\ K.*"]/title/text()',data) FROM bookstore;
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
【问题讨论】:
标签: sql xml postgresql xpath