我有三個表:如何從3個表中選擇值+計數()
tbl_Publisher [Publisher_ID, addr,account-num,...,city];
tbl_Title [Title_ID, frequency, publisher,.., Publisher_ID];
tbl_Invoice [Invoice_ID, ordered_Date,...,Title_ID];
我想通過出版迴歸的標題列表,並且每個題目都有它包含發票的計數。在一個結果集中。 我使用一個存儲過程如下:
PROCEDURE [dbo].[usp_GetTitlesbyPublisher]
-- Add the parameters for the stored procedure here
@PublisherID INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
-- Insert statements for procedure here
SELECT Title_ID,TitleName,pub_type,Frequency , Holdings ,tbl_Title.publisher ,section ,tbl_Title.Publisher_ID from tbl_Title, tbl_Publisher
where tbl_Title.Publisher_ID = tbl_Publisher.Publisher_ID
and @PublisherID = tbl_Publisher.Publisher_ID
END
我怎樣才能通過每個標題返回發票的號碼?
標記您正在使用的dbms。該代碼是特定於產品的。 – jarlh
使用SQL Server的存儲過程,我添加了需要的標籤。 –
但我看不到sql-server標籤。 – jarlh