
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 1.41 KB | hits: 9 | expires: Never
getting multiple values from one table and using to retrive data from other table in stored procedure in sql server [closed]
cart table
CartId,
PrdouctId -> should retrieve data from productinfo table
EmailId ->should Retrieve data from cart table that who many cart are register in this EmailId
cost,
Quantity ,
Ram -> contains HardWareId
GraphicCard ->contains HardWareId
ScreenSize ->contains HardWareId
ProductInfo Table
ProductId,
BrandlName,
ModelName,
Processor,
HardwareInfo table
HardWareId,
HardwareName,
HarwareCost,
Select @ProductId =[productId],@Ram = [Ram] from cart where EmailId = @EmailId
Select [BrandName],[ModelName] from ProductInfo where ProductId = @productId
select [HardwareName],[HardwareCost] from HardwareInfo where HardwareId = @Ram
create procedure GetCartByEmailId
@EmailId int
as
select P.BrandName,
P.ModelName,
HR.HardwareName as RamName,
HR.HardwareCost as RamCost,
HG.HardwareName as GraphicCard,
HG.HardwareCost as GraphicCardCost,
HS.HardwareName as ScreenSize
from Cart as C
inner join ProductInfo as P
on C.ProductId = P.ProductId
left outer join HardwareInfo as HR
on C.Ram = HR.HardwareID
left outer join HardwareInfo as HG
on C.GraphicCard = HG.HardwareID
left outer join HardwareInfo as HS
on C.ScreenSize = HS.HardwareID
where C.EmailId = @EmailId