如何从2个表创建报告? [英] How to create a report from 2 tables?
问题描述
大家好!我设法从1个表创建报告.我的问题是如何从2个表(由oracle 10g DB填充)创建报告?
我有一个带有2个表的DataSet,如下所示:
表客户:
ID(PK)
NAME
地址
表产品:
ID
PRODUCT_NAME
买方(FK-来自客户的ID)
好的.现在,我想向所有客户及其购买者显示报告,例如:
ID NAME
3斯科特
BUYER PRODUCT_NAME
3电视
3辆车
3玩具
ID NAME
4约翰
等等
------------------------------------
预先感谢您的帮助.
Hello everyone! I''ve managed to create reports from 1 table. My question is how to create a report from 2 tables (are filled from oracle 10g DB)?
I have a DataSet with 2 tables like this:
Table Customer:
ID (PK)
NAME
ADRESS
Table Producs:
ID
PRODUCT_NAME
BUYER (FK - ID from Customer)
Ok. Now I want to display the report with all customers and what they bought, as an example:
ID NAME
3 Scott
BUYER PRODUCT_NAME
3 TV
3 CAR
3 TOY
ID NAME
4 John
and so on
------------------------------------
Thank you in advance for your help.
推荐答案
您想要的关键字是内部联接
从客户c内部连接产品p中选择c.Name,c.Address和p.ProductName,其中c.ID = p.Buyer
The keyword you want is inner join
select c.Name, c.Address, p.ProductName from Customer c inner join Product p where c.ID = p.Buyer
这就是答案,感谢您的帮助.
祝你有美好的一天,
三都
That was the answer and thank you for help.
Have a great day,
Sandu
这篇关于如何从2个表创建报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!