开发者

SQL Server: stored procedure related

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜