Click here to Skip to main content
16,014,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i need to make an update statement connect with 3 table, the purpose of connecting the table is to update 'stockmaster' table but i am using the unitname and category name in the form but in database i am saving the unitid and categoryid insted. i have connection with these three table by connecting stockmaster.unit = stockunit.id and stockmaster.categoryid=stockcatgegory.categoryid. the select statement as below

SQL
SELECT StockMaster.ItemId,StockMaster.ItemCode,StockMaster.ItemName,StockMaster.ItemDescription,StockUnit.Uname, 
                     StockCategory.CategoryName,StockMaster.ManufacturedBy,StockMaster.ProductionDate,StockMaster.ExpiryDate,StockMaster.AvgCostPrice,  
                     StockMaster.StkReorderQty, StockMaster.DeleteYNID, StockMaster.UserID, StockMaster.TimeNow, StockMaster.datenow  
                     FROM  StockMaster INNER JOIN  
                      StockUnit ON StockMaster.Unit =StockUnit.ID INNER JOIN  
                      StockCategory ON StockMaster.CategoryID = StockCategory.CategoryId where Itemid = 1
Posted
Updated 31-Jan-12 4:51am
v2
Comments
Ankur\m/ 31-Jan-12 11:07am    
Not sure what you are asking. What do want to update?

Hi, Use below query

SQL
UPDATE dbo.Approved
SET dbo.Approved.Groupid=dbo.Locations.ID
FROM dbo.Approved, dbo.Locations
WHERE dbo.Approved.Location = dbo.Locations.Location_Name


SQL
UPDATE dbo.Approved
SET dbo.Approved.Groupid=dbo.Locations.ID
FROM dbo.Approved inner join dbo.Locations On
dbo.Approved.Location = dbo.Locations.Location_Name
 
Share this answer
 
v2
better write update statement for 3 tables separately one after the other in single button1_click
 
Share this answer
 

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