连接表中两个不同行的字符串(concatenating strings from two different rows in a table)

编程入门 行业动态 更新时间:2024-10-22 14:41:38
连接表中两个不同行的字符串(concatenating strings from two different rows in a table)

我们正在尝试在产品中重写SQL。 该产品将XML存储在表中,如下所示:

XML_STORAGE - UID IDENTITY - PARENT_ID INTEGER - SEQ INTEGER - XML VARCHAR(3800)

目前的做法如下:

检索PARENT_ID = n的所有ROWS。 然后遍历代码中的获取行,并在解析之前将XML字符串连接成一个大型XML。 SEQ列用于对结果进行ORDER,以便可以正确连接XML字符串。 希望这很清楚。

我们要做的是重做这个,这样我们就可以使用SQL变量来检索整个字符串,并从DB2中获取一行。 是否有一个DB2函数允许我们将所有这些行中的字符串连接成结果集中的一个大字符串。 怎么会这样的SQL看起来。 请告诉我。 任何帮助深表感谢。

谢谢! - Azeem

We are attempting to rework the SQL in a product. The product stores XML in a table as follows:

XML_STORAGE - UID IDENTITY - PARENT_ID INTEGER - SEQ INTEGER - XML VARCHAR(3800)

The current way of doing this is as follows:

Retrieve all ROWS for PARENT_ID = n. Then go over the fetched rows in the code and concatenate the XML strings into one large XML before parsing. The SEQ column is used to ORDER the result so the XML strings can be concatenated properly. Hopefully that is clear.

What we are attempting to do is rework this so we can use a SQL variant to retrieve the whole string and just fetch one row back from DB2. Is there a DB2 function that will allow us to concatenate the string in all of these rows into one large string in the resultset. How would such a SQL look. Please let me know. Any help is much appreciated.

Thanks! - Azeem

最满意答案

检查DB2中的递归查询,如此处所述

Check recursive queries in DB2, such as mentioned here

更多推荐

本文发布于:2023-08-05 10:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1431162.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   同行   两个   concatenating   rows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!