从2个表ASP加入选定的列

发布于 2025-02-14 00:01:16 字数 1937 浏览 0 评论 0原文

我正在尝试找到一种从两个表中显示所选列的方法。表1是库存列表,表2是客户要求的项目列表。

Table 1: Inventory

CodeDescriptionUnitPriceQtyOnHandStatus
1bookP200100AV
2bagP300120AV
3penP2090AV
4eraserP20190AV

Table 2: Order

OrderItemsInvCodeQtyOrderedTotalStatus
11102000OP
12206000OP
1310200OP
12103000OP
21306000OP

From this table, I want to print some selected data from Order table that has OrderItems代码为1,以及库存表的一些数据。我该如何实现?我需要使用加入吗?如果是这样,我该怎么办?

Note: The number in the headers are what table

Result:

Code (2)Description (1)QtyOrdered (2)UnitPrice (1)Total (2)
1book10P2002000
2bag20P3006000
3pen30P20200
2bag10P3003000

also, can I data bind it?

I am trying to find a way to display selected columns from two tables. Table 1 is an inventory list and table 2 is a list of items requested by a customer.

Table 1: Inventory

CodeDescriptionUnitPriceQtyOnHandStatus
1bookP200100AV
2bagP300120AV
3penP2090AV
4eraserP20190AV

Table 2: Order

OrderItemsInvCodeQtyOrderedTotalStatus
11102000OP
12206000OP
1310200OP
12103000OP
21306000OP

From this table, I want to print some selected data from Order table that has OrderItems code of 1, along with some data from Inventory table. How do I achieve this? do I need to use join? if so, how do I do it?

Note: The number in the headers are what table

Result:

Code (2)Description (1)QtyOrdered (2)UnitPrice (1)Total (2)
1book10P2002000
2bag20P3006000
3pen30P20200
2bag10P3003000

also, can I data bind it?

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

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

发布评论

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

评论(1

删除→记忆 2025-02-21 00:01:17

continue

if you are using datatables you can do something like it:

dt1.AsEnumerable().Join(dt2.AsEnumerable(),                                                                                                                                     
d2=> d2.Field<string>("key"),                                                                                                                                         
d1=> d1.Field<string>("fKey"),
(d2, d1) => new { d2, d1})
.ToList()
.Select(a=> new {/*your desired fields*/})

if you are using ef, u can achieve something similar without extra .AsEnumrabel()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文