Joining Three Tables
-
Hi,my requirement is i want to join three tables in which first and second table are related and second and third tables are related.I want to get data from all three tables so how it is possible. Pls send me some reply. GIRISH
-
Hi,my requirement is i want to join three tables in which first and second table are related and second and third tables are related.I want to get data from all three tables so how it is possible. Pls send me some reply. GIRISH
Hi, You could do a join on the three tables with their foreign keys. After the join you would be able to get all data from the three tables. Depends on your database but here is an example: SQL (JOIN)[^] Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
-
Hi, You could do a join on the three tables with their foreign keys. After the join you would be able to get all data from the three tables. Depends on your database but here is an example: SQL (JOIN)[^] Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's :bob: :)Programm3r My Blog: ^_^
Thanx for ur reply, if possible just see this query and tell me wt is wrong in this, select PurPRMaster.*,StkItemMaster.Name as IName,StkItemMaster.Unit,PurPRTrans.* FROM PurPRMaster inner join purOrderMaster on PurPrmaster.prno=PurOrderMaster.prno inner join purprtrans on purmaster.id=purtrans.mastid inner join StkItemMaster on StkItemMaster.Code=PurPRTrans.ItemCode It is doing cross multiplication. wt could be the reason. Thanks in advance. GIRISH
-
Hi,my requirement is i want to join three tables in which first and second table are related and second and third tables are related.I want to get data from all three tables so how it is possible. Pls send me some reply. GIRISH
============================== TABLE [Customers] ( ============================== [CustomerID] [CompanyName] [ContactName] [ContactTitle] [Address] [City] [Region] [PostalCode] [Country] [Phone] [Fax] CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED ( [CustomerID] ) ON [PRIMARY] ================================== TABLE Employee =================================== EmployeeID LastName FirstName Title TitleOfCourtesy BirthDate HireDate Address City Region PostalCode Country HomePhone Extension Photo Notes ReportsTo PhotoPath Table Order ======================== 3 OrderID 0 CustomerID 0 EmployeeID 0 OrderDate 0 RequiredDate 0 ShippedDate 0 ShipVia 0 Freight 0 ShipName 0 ShipAddress 0 ShipCity 0 ShipRegion 0 ShipPostalCode 0 ShipCountry SELECT dbo.Customers.CompanyName, dbo.Employees.LastName, dbo.Employees.FirstName, dbo.Orders.OrderDate, dbo.Orders.RequiredDate FROM dbo.Orders INNER JOIN dbo.Customers ON dbo.Orders.CustomerID = dbo.Customers.CustomerID INNER JOIN dbo.Employees ON dbo.Orders.EmployeeID = dbo.Employees.EmployeeID Rami Abd Alhalim