Click here to Skip to main content
16,021,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
 USE [cms]
GO
/****** Object:  StoredProcedure [dbo].[SpGetRelatedProducts]    Script Date: 10/10/2012 23:55:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter proc [dbo].[SpGetAllProducts](@cateid int)
AS
select *
from product 
inner join subcategory on subcategory.subcate_id = product.subcate_id
inner join category on subcategory.cate_id = @cateid




i want that all the products, which belong from different subcategory and these subcategories belongs from same category and also the columns of the subcategory table, but in above code thr is a issue that each row repeating itself too many times...?
Posted

1 solution

SQL
SELECT distinct *
  FROM product 
         INNER JOIN subcategory ON subcategory.subcate_id = product.subcate_id
         INNER JOIN category ON subcategory.cate_id = @cateid
 
Share this answer
 
Comments
Abhinav S 10-Oct-12 23:38pm    
My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900