June 4, 2005 at 2:17 pm
This is a stored proceedure that i am using in my application to return (Size)(Color) for two seperate drop down list. Both of the drop list use the same procedure ,(one procedure is cmdcolor,,, and the other is cmdsize)- two different names with the same proceedure to accomplish two different things to populate a size choice and a color choice ddl.
what i am looking for here is for someone that can explain the logic behind this so that i can better understand what i am looking at.
Thank you.
/* Returns the attributes of a specified type
for a specified product
ALTER PROCEDURE procProductAttributes
@idProduct int, @AttributeCategoryName varchar(
AS
SELECT Attribute.AttributeName
FROM ((Product INNER JOIN ProductAttribute
ON Product.ProductID = ProductAttribute.ProductID)
INNER JOIN Attribute
ON ProductAttribute.AttributeID = Attribute.AttributeID)
INNER JOIN AttributeCategory
ON Attribute.AttributeCategoryID = AttributeCategory.AttributeCategoryID
WHERE Product.ProductID = @idProduct
Dam again!
June 6, 2005 at 2:48 am
Mr Grasshopper,
What you have here is a stored procedure that joins your product table to the product attribute table. The other joins are to allow you to join to the AttributeCategory table where you will be able to specify either Size or Colour attribute.
When you run the sp with both a ProductID and an attribute of either Size or Colour that is what it will return for you.
June 6, 2005 at 4:52 pm
Thank you!
Dam again!
June 6, 2005 at 6:50 pm
I am not sure how to ask this question so i will just keep it simple.
why referr the first @category int , if referred to at the end, by the WHERE clause?
========================Thanks=======================
ALTER Procedure
ProductsByCategory
(
@CategoryID
int
)
AS
SELECT
ProductID,
ModelName,
UnitCost,
ProductImage
FROM
Products
WHERE
CategoryID = @CategoryID
ORDER BY
ModelName,
ModelNumber
Dam again!
June 6, 2005 at 7:06 pm
Like this example below; I am banging my head against the wall TYRING
ALTER Procedure
ShoppingCartMigrate
(
@OriginalCartId
nvarchar(50),
@NewCartId
nvarchar(50)
)
AS
UPDATE
ShoppingCart
SET
CartID = @NewCartId
WHERE
CartID = @OriginalCartId
Dam again!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply