这就是我所拥有的:
Store_Bill_Item_Details
表格中。这就是我想要做的事情:
Store_Bill_Item_Details
中为该人拥有的所有Bill_No
运行了一个SELECT。Bill_No
的列表,我希望它以递归方式搜索Store_Bill_Details
以列出所有项目及其费率。因此,对于输入的PersonID,我的查询结果应如下所示:
比尔1:
bill1的详细信息
比尔2:
bill2的详细信息
这就是我没有用的东西。
USE My_Database
Select I.Bill_No , ( SELECT * FROM Store_Bill AS I1
INNER JOIN
Store_Bill_Details AS ID
ON
ID.Bill_No=II.Bill_No)
FROM Store_Bill_Item_Details AS BD
INNER JOIN
Store_Bill AS I
ON
BD.Item_Code=I.Bill_No
请帮帮我,伙计们!
答案 0 :(得分:1)
SELECT * FROM Store_Bill AS I1
INNER JOIN Store_Bill_Details AS ID ON ID.Bill_No=I1.Bill_No
INNER JOIN Store_Bill_Item_Details AS BD ON BD.Item_Code=I1.Bill_No
或试试这个
select * from
(select Person,bill,null as a,null as b....
from Store_Bill_Item_Details
union
select Null,bill,<field1>,<field2>,<field3>...
from Store_Bill_Details) aa
order by bill,a