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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. query to get results from 4 tables

query to get results from 4 tables

Scheduled Pinned Locked Moved Database
databasehelptutorialquestion
8 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.
  • I Offline
    I Offline
    icanmakeiteasy
    wrote on last edited by
    #1

    i am bit confused about my question only please help me to get the result i hav 3 tables table1,table2,table3

    table1
    uid shiftcode startdate enddate
    100 s1 xxxxxx xxxxx
    101 s1 xxxxxx xxxxx
    102 s1 xxxxxx xxxxx

    table2
    uid patterncode
    103 p1

    table3
    uid shiftcode patterncode
    103 s2 p1

    i want shiftcode's of 100 to 103 users how to get plzz help me....

    icanmakeiteasy

    W V I 3 Replies Last reply
    0
    • I icanmakeiteasy

      i am bit confused about my question only please help me to get the result i hav 3 tables table1,table2,table3

      table1
      uid shiftcode startdate enddate
      100 s1 xxxxxx xxxxx
      101 s1 xxxxxx xxxxx
      102 s1 xxxxxx xxxxx

      table2
      uid patterncode
      103 p1

      table3
      uid shiftcode patterncode
      103 s2 p1

      i want shiftcode's of 100 to 103 users how to get plzz help me....

      icanmakeiteasy

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      I think your question is lacking some information. Could you explain the logic of combining those rows together. Is it for example that when table1 has shiftcode s1 you want shiftcode s2 from table3 or is the idea to go through table2 and join patterncode, but then again how does pattern code relate to shiftcode in table1 etc.

      The need to optimize rises from a bad design.My articles[^]

      I 1 Reply Last reply
      0
      • I icanmakeiteasy

        i am bit confused about my question only please help me to get the result i hav 3 tables table1,table2,table3

        table1
        uid shiftcode startdate enddate
        100 s1 xxxxxx xxxxx
        101 s1 xxxxxx xxxxx
        102 s1 xxxxxx xxxxx

        table2
        uid patterncode
        103 p1

        table3
        uid shiftcode patterncode
        103 s2 p1

        i want shiftcode's of 100 to 103 users how to get plzz help me....

        icanmakeiteasy

        V Offline
        V Offline
        venu656
        wrote on last edited by
        #3

        it is very simple use joins and co related sub queries

        I 1 Reply Last reply
        0
        • W Wendelius

          I think your question is lacking some information. Could you explain the logic of combining those rows together. Is it for example that when table1 has shiftcode s1 you want shiftcode s2 from table3 or is the idea to go through table2 and join patterncode, but then again how does pattern code relate to shiftcode in table1 etc.

          The need to optimize rises from a bad design.My articles[^]

          I Offline
          I Offline
          icanmakeiteasy
          wrote on last edited by
          #4

          thx for reply... user 103 is on bench so his shift code is s2 or any other if user got work for some days simply he moves to table1 with his working days and his work code(s1,s2,s3..etc) just i want work code(shiftcode) of 100 to 103 users between given dates

          icanmakeiteasy

          modified on Tuesday, February 17, 2009 8:18 AM

          W 1 Reply Last reply
          0
          • V venu656

            it is very simple use joins and co related sub queries

            I Offline
            I Offline
            icanmakeiteasy
            wrote on last edited by
            #5

            i am little poor in joins and sub queries can u plzz give me some idea

            icanmakeiteasy

            1 Reply Last reply
            0
            • I icanmakeiteasy

              thx for reply... user 103 is on bench so his shift code is s2 or any other if user got work for some days simply he moves to table1 with his working days and his work code(s1,s2,s3..etc) just i want work code(shiftcode) of 100 to 103 users between given dates

              icanmakeiteasy

              modified on Tuesday, February 17, 2009 8:18 AM

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              So did I understand correctly, table1 contains info about users andtheir work periods and you want to find users having work in certain period. If that's the case, could it be something like

              select ...
              from table1
              where startdate between periodstart and periodend
              or enddate between periodstart and periodend

              where the periodstart and periodend are the dates you're interested in

              The need to optimize rises from a bad design.My articles[^]

              I 1 Reply Last reply
              0
              • W Wendelius

                So did I understand correctly, table1 contains info about users andtheir work periods and you want to find users having work in certain period. If that's the case, could it be something like

                select ...
                from table1
                where startdate between periodstart and periodend
                or enddate between periodstart and periodend

                where the periodstart and periodend are the dates you're interested in

                The need to optimize rises from a bad design.My articles[^]

                I Offline
                I Offline
                icanmakeiteasy
                wrote on last edited by
                #7

                thx for reply...

                srry... i am mistaken
                table3 does not have uid column
                table3
                shiftcode patterncode
                s2 p1

                i want the shift code of users (100 to 103) between given periodic times by using given query i can not get the shift code of user 103 where does not exist in the table1, so i have to get the shift code from table3, here table3 having patterncode only, now i have to get the paaterncode from table2... using that i want to show the shiftcode of user 103.... am i clear now??

                icanmakeiteasy

                1 Reply Last reply
                0
                • I icanmakeiteasy

                  i am bit confused about my question only please help me to get the result i hav 3 tables table1,table2,table3

                  table1
                  uid shiftcode startdate enddate
                  100 s1 xxxxxx xxxxx
                  101 s1 xxxxxx xxxxx
                  102 s1 xxxxxx xxxxx

                  table2
                  uid patterncode
                  103 p1

                  table3
                  uid shiftcode patterncode
                  103 s2 p1

                  i want shiftcode's of 100 to 103 users how to get plzz help me....

                  icanmakeiteasy

                  I Offline
                  I Offline
                  icanmakeiteasy
                  wrote on last edited by
                  #8

                  i got solved this problem [^] from this forum

                  icanmakeiteasy

                  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