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 4 Tables in SQL Server

Joining 4 Tables in SQL Server

Scheduled Pinned Locked Moved Database
cssdatabasesql-serversysadmin
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.
  • M Offline
    M Offline
    Member 11546783
    wrote on last edited by
    #1

    Hi Friends I have to join 4 tables in SQL Server and need to Show Specific Coulmns in Data Grid View From First Table User Tabel and feild User_ID, User_Name, User_Email, User_Password, UserR_ID, UserS_ID, Co_ID, User_Remark from Second Table User_right Tabel and feild UserR_ID, User_Right .from third Table User_Status Tabel and feild UserS_ID, User_Status From Fourth Table Company and feild Co_ID, Co_Name From First Table i need to show User_ID, User_Name, User_Email, User_Password, User_Remark 2.from Second Table i need to show User_Right 3.from third Table i need to show User_Status 4.From Fourth Table i need to show Co_Name Try to Reply to this as soon as possible Friends...Thanks..

    M 1 Reply Last reply
    0
    • M Member 11546783

      Hi Friends I have to join 4 tables in SQL Server and need to Show Specific Coulmns in Data Grid View From First Table User Tabel and feild User_ID, User_Name, User_Email, User_Password, UserR_ID, UserS_ID, Co_ID, User_Remark from Second Table User_right Tabel and feild UserR_ID, User_Right .from third Table User_Status Tabel and feild UserS_ID, User_Status From Fourth Table Company and feild Co_ID, Co_Name From First Table i need to show User_ID, User_Name, User_Email, User_Password, User_Remark 2.from Second Table i need to show User_Right 3.from third Table i need to show User_Status 4.From Fourth Table i need to show Co_Name Try to Reply to this as soon as possible Friends...Thanks..

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      What have you tried, this seems to be a very simple exercise in organising your joins. Table 1 has all the foriegn keys to the other tables.

      Never underestimate the power of human stupidity RAH

      M 1 Reply Last reply
      0
      • M Mycroft Holmes

        What have you tried, this seems to be a very simple exercise in organising your joins. Table 1 has all the foriegn keys to the other tables.

        Never underestimate the power of human stupidity RAH

        M Offline
        M Offline
        Member 11546783
        wrote on last edited by
        #3

        can you do for me i am new i have tried but i can not

        L M 2 Replies Last reply
        0
        • M Member 11546783

          can you do for me i am new i have tried but i can not

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          https://startpage.com/do/search?query=sql+server+join[^] This is basic SQL; reading any of those listed sites would explain in a few minutes how to do so.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

          1 Reply Last reply
          0
          • M Member 11546783

            can you do for me i am new i have tried but i can not

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Lets see what you have tried and we will try and correct it.

            Never underestimate the power of human stupidity RAH

            M 1 Reply Last reply
            0
            • M Mycroft Holmes

              Lets see what you have tried and we will try and correct it.

              Never underestimate the power of human stupidity RAH

              M Offline
              M Offline
              Member 11546783
              wrote on last edited by
              #6

              SELECT UserT.User_ID, UserT.User_Name, UserT.User_Email, UserT.User_Password, UserRightT.User_Right, UserStatusT.UserStatus, CompanyT.Co_Name, UserT.User_Remark
              FROM CompanyT INNER JOIN
              UserT ON CompanyT.Co_ID = UserT.Co_ID CROSS JOIN
              UserStatusT CROSS JOIN
              UserRightT

              query work but record again agai show in grid

              M 1 Reply Last reply
              0
              • M Member 11546783

                SELECT UserT.User_ID, UserT.User_Name, UserT.User_Email, UserT.User_Password, UserRightT.User_Right, UserStatusT.UserStatus, CompanyT.Co_Name, UserT.User_Remark
                FROM CompanyT INNER JOIN
                UserT ON CompanyT.Co_ID = UserT.Co_ID CROSS JOIN
                UserStatusT CROSS JOIN
                UserRightT

                query work but record again agai show in grid

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                I'm pretty sure you should replace the cross joins with either inner or left joins. Read this article [^]to help understand the joins. Displaying the data in a grid is NOT a database problem, choose the correct forum (web/wpf/winforms) to get support on the UI.

                Never underestimate the power of human stupidity RAH

                M 1 Reply Last reply
                0
                • M Mycroft Holmes

                  I'm pretty sure you should replace the cross joins with either inner or left joins. Read this article [^]to help understand the joins. Displaying the data in a grid is NOT a database problem, choose the correct forum (web/wpf/winforms) to get support on the UI.

                  Never underestimate the power of human stupidity RAH

                  M Offline
                  M Offline
                  Member 11546783
                  wrote on last edited by
                  #8

                  thank you

                  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