开发者

SQL Server: stored procedure related

开发者 https://www.devze.com 2023-02-19 11:38 出处:网络
I have two input parameters shopid and categoryid I want to create a stored procedure for categ开发者_如何学运维oryproductlist for displaying products related to categoryid. I have a table product wi

I have two input parameters shopid and categoryid

I want to create a stored procedure for categ开发者_如何学运维oryproductlist for displaying products related to categoryid. I have a table product with columns productid , shopid , title and I have a table category with columns shopid,title,logical code, categoryid

Can anyone tell me how to write a stored procedure for categoryproductlist with these input parameters?


Have a go at this:

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 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号