从2个表ASP加入选定的列
我正在尝试找到一种从两个表中显示所选列的方法。表1是库存列表,表2是客户要求的项目列表。
Table 1: Inventory
Code | Description | UnitPrice | QtyOnHand | Status |
---|---|---|---|---|
1 | book | P200 | 100 | AV |
2 | bag | P300 | 120 | AV |
3 | pen | P20 | 90 | AV |
4 | eraser | P20 | 190 | AV |
Table 2: Order
OrderItems | InvCode | QtyOrdered | Total | Status |
---|---|---|---|---|
1 | 1 | 10 | 2000 | OP |
1 | 2 | 20 | 6000 | OP |
1 | 3 | 10 | 200 | OP |
1 | 2 | 10 | 3000 | OP |
2 | 1 | 30 | 6000 | OP |
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) |
---|---|---|---|---|
1 | book | 10 | P200 | 2000 |
2 | bag | 20 | P300 | 6000 |
3 | pen | 30 | P20 | 200 |
2 | bag | 10 | P300 | 3000 |
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
Code | Description | UnitPrice | QtyOnHand | Status |
---|---|---|---|---|
1 | book | P200 | 100 | AV |
2 | bag | P300 | 120 | AV |
3 | pen | P20 | 90 | AV |
4 | eraser | P20 | 190 | AV |
Table 2: Order
OrderItems | InvCode | QtyOrdered | Total | Status |
---|---|---|---|---|
1 | 1 | 10 | 2000 | OP |
1 | 2 | 20 | 6000 | OP |
1 | 3 | 10 | 200 | OP |
1 | 2 | 10 | 3000 | OP |
2 | 1 | 30 | 6000 | OP |
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) |
---|---|---|---|---|
1 | book | 10 | P200 | 2000 |
2 | bag | 20 | P300 | 6000 |
3 | pen | 30 | P20 | 200 |
2 | bag | 10 | P300 | 3000 |
also, can I data bind it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
continue
if you are using datatables you can do something like it:
if you are using ef, u can achieve something similar without extra
.AsEnumrabel()