我有两个输入参数shopid
和categoryid
我想为categoryproductlist
创建一个存储过程,用于显示与categoryid
相关的产品。我有一个包含product
列的表productid , shopid , title
,我有一个表category
,其中列shopid,title,logical code, categoryid
有人能告诉我如何使用这些输入参数为categoryproductlist
编写存储过程吗?
答案 0 :(得分:2)
快来看看:
CREATE PROCEDURE p_CategoryProductList
@CategoryID INT
@ShopID INT
AS
SELECT
c.itle as CategoryTitle,
c.[logical code],
p.title as ProductTitle
FROM Product p
INNER JOIN tblcategoryproduct cp on p.ProductID=cp.ProductID
INNER JOIN Category c on c.CategoryID=cp.CategoryID
WHERE c.ShopID=@ShopID
AND c.CategoryID=@CategoryID