如何从 ITEM 表中获取所有行,这些行是父 ITEM 表行的子行,其中关系单独存储?

发布于 2024-08-10 06:58:41 字数 563 浏览 1 评论 0原文

如何从 ITEM 表中获取所有行,这些行是父 ITEM 表行的子行,其中关系单独存储?我怎样才能加入来做到这一点? “从 ITEM 表中获取所有行,这些行是此特定 ITEM 表行的子项,此父项的所有子项,其中关系存储在单独的 RELATIONSHIP 表中”

因此,假设有一个 ITEMS 和一个 RELATIONSHIPS 表。关键列是:

ITEMS
* ID
* << other columns>>

RELATIONSHIPS
* PARENT_ID
* CHILD_ID

我试图了解 DataSet / DataRelation 方法是否可以以某种方式映射这些关系。例如,如果我基本上想要一种方法来实现请求“基于 RELATIONSHIPS 表,给定父 ITEM DataRow,以 DataRow[] 形式给我所有子 ITEMS”,有没有办法使用 DataRelation 来做到这一点?如果不是的话,使用数据集方法来做到这一点最简单的方法是什么?

编辑:也就是说,假设我正在使用一个数据集,并且在数据集中,我为上面描述的每个物理数据库表都有一个数据表。

谢谢

How do I get all rows from ITEM table, which are children of a parent ITEM table row, where relationship is stored separately? How can I do a join to do this? "get all rows from ITEM table, which are children of this specific ITEM table row, all child items from this parent item, where relationship is stored in separate RELATIONSHIP table"

So given there is an ITEMS and a RELATIONSHIPS table. The key columns are:

ITEMS
* ID
* << other columns>>

RELATIONSHIPS
* PARENT_ID
* CHILD_ID

I'm trying to understand whether the DataSet / DataRelation approach could somehow map these relations. For example if I basically want a way to implement the request "Give me all children ITEMS in a DataRow[] form, given a parent ITEM DataRow, based on the RELATIONSHIPS table", is there a way to do this using a DataRelation? Of if not what would be the easiest way to do this using the DataSet approach?

EDIT: That is, assuming I am using a DataSet, and within the DataSet I have one DataTable for each of the physical database tables I described above.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生生漫 2024-08-17 06:58:41

在我的脑海中,您正在寻找大致这个解决方案(并且我不完全确定我是否正确理解您的数据结构):

SELECT child.othercolumns
FROM items AS child, relationships AS r, items AS parent
WHERE r.parent_id=parent.id AND r.child_id=child.id

Top of my head, you're looking for roughly this solution (and I'm not entirely certain if I understand your datastructure correctly):

SELECT child.othercolumns
FROM items AS child, relationships AS r, items AS parent
WHERE r.parent_id=parent.id AND r.child_id=child.id
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文