XQuery的FLOWR表达式
控制使用FLOWR替代XQuery路径表达式。
FLOWR是For,Let,Where,Order by, Return的谓词首字母缩写。
下面演示数据表,来自http://www.cnblogs.com/insus/archive/2012/02/26/2368323.html 的[dbo].[tbDevLanguage]
SELECT [ID],[languages].query('
for $l in /Languages/language
order by $l/@name
return ($l)
') AS [language]
FROM [dbo].[tbDevLanguage]
for $l in /Languages/language
order by $l/@name
return ($l)
') AS [language]
FROM [dbo].[tbDevLanguage]
for是XPath'/Languages/language' 的表达式所有元素赋值至$l变量中。
order by按元素排序。
return把结果返回至$l变量中。