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. Retrieving data from multiple tables

Retrieving data from multiple tables

Scheduled Pinned Locked Moved Database
databasehelpquestion
4 Posts 2 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.
  • H Offline
    H Offline
    HinJinShah
    wrote on last edited by
    #1

    Hello! I am trying to retirve data from almost five tables simultaneously, but having problems in use of a single query!!! Here is the sample of thouse five tables students: stuid, classID, sectionID, termID, sessionID, stuName, other fields Classes: classID, className Sections: sectionID, sectionName Terms: termID, termName Sessions: sessionID, sessionName NOw if i want to extract data with a single query in somewhat this form stuName, className, sectionName, termName, sessionName Can someone help me in this, as to how the best query can be formed? thank you!! -- modified at 1:28 Monday 30th July, 2007

    E 1 Reply Last reply
    0
    • H HinJinShah

      Hello! I am trying to retirve data from almost five tables simultaneously, but having problems in use of a single query!!! Here is the sample of thouse five tables students: stuid, classID, sectionID, termID, sessionID, stuName, other fields Classes: classID, className Sections: sectionID, sectionName Terms: termID, termName Sessions: sessionID, sessionName NOw if i want to extract data with a single query in somewhat this form stuName, className, sectionName, termName, sessionName Can someone help me in this, as to how the best query can be formed? thank you!! -- modified at 1:28 Monday 30th July, 2007

      E Offline
      E Offline
      Eliz k
      wrote on last edited by
      #2

      SELECT stuName = s.stuName, className = c.className, sectionName = sc.sectionName, termName = t.termName, sessionName = ss.sessionName FROM students s LEFT OUTER JOIN Classes c ON s.classID = c.classID LEFT OUTER JOIN Sections sc ON s.sectionID = sc.sectionID LEFT OUTER JOIN Terms t ON s.termID = t.termID LEFT OUTER JOIN Sessions ss ON s.sessionID = ss.sessionID Eliz.K

      H 1 Reply Last reply
      0
      • E Eliz k

        SELECT stuName = s.stuName, className = c.className, sectionName = sc.sectionName, termName = t.termName, sessionName = ss.sessionName FROM students s LEFT OUTER JOIN Classes c ON s.classID = c.classID LEFT OUTER JOIN Sections sc ON s.sectionID = sc.sectionID LEFT OUTER JOIN Terms t ON s.termID = t.termID LEFT OUTER JOIN Sessions ss ON s.sessionID = ss.sessionID Eliz.K

        H Offline
        H Offline
        HinJinShah
        wrote on last edited by
        #3

        Thank You Eliz! One thing more, also if i want to get the record of a single student, can i used the where clause after joins like where s.stuid = '2222' ??? thanks!!!

        E 1 Reply Last reply
        0
        • H HinJinShah

          Thank You Eliz! One thing more, also if i want to get the record of a single student, can i used the where clause after joins like where s.stuid = '2222' ??? thanks!!!

          E Offline
          E Offline
          Eliz k
          wrote on last edited by
          #4

          Yes you can :) Eliz.K www.oin1.com

          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