Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Joining Three Tables

Joining Three Tables

Scheduled Pinned Locked Moved Database
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ShuklaGirish
    wrote on last edited by
    #1

    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

    P R 2 Replies Last reply
    0
    • S ShuklaGirish

      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

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      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: ^_^

      S 1 Reply Last reply
      0
      • P Programm3r

        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: ^_^

        S Offline
        S Offline
        ShuklaGirish
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • S ShuklaGirish

          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

          R Offline
          R Offline
          Rami Said Abd Alhalim
          wrote on last edited by
          #4

          ============================== 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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups