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. how to write the querry for user belongs to a company all related branches

how to write the querry for user belongs to a company all related branches

Scheduled Pinned Locked Moved Database
tutorialdatabasesql-serversysadmin
3 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.
  • D Offline
    D Offline
    developerit
    wrote on last edited by
    #1

    iam usin sql server 2000, the table are as follows tbluser ======== username nvarchar(50) pk usertype nvarchar(50) companyid nvarchar(50) fk tblcompany ========== companyid nvarchar(50) pk company name nvarchar(50) tblbranch ======== branchid nvarchar(50) pk branchname nvarchar(50) companyid nvarchar(50) location nvarchar(50) how to write the querry for user belongs to a company all related branches please give the example which helps me.

    M D 2 Replies Last reply
    0
    • D developerit

      iam usin sql server 2000, the table are as follows tbluser ======== username nvarchar(50) pk usertype nvarchar(50) companyid nvarchar(50) fk tblcompany ========== companyid nvarchar(50) pk company name nvarchar(50) tblbranch ======== branchid nvarchar(50) pk branchname nvarchar(50) companyid nvarchar(50) location nvarchar(50) how to write the querry for user belongs to a company all related branches please give the example which helps me.

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

      Now you are pushing it, what have you tried? Use the inner join example and extend it to include the user table. Don't just ask for the code, put up something you have tried and we may point out whee you are going wrong. Asking for examples all the time is like asking us to write your code for you and is :mad: discouraged.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • D developerit

        iam usin sql server 2000, the table are as follows tbluser ======== username nvarchar(50) pk usertype nvarchar(50) companyid nvarchar(50) fk tblcompany ========== companyid nvarchar(50) pk company name nvarchar(50) tblbranch ======== branchid nvarchar(50) pk branchname nvarchar(50) companyid nvarchar(50) location nvarchar(50) how to write the querry for user belongs to a company all related branches please give the example which helps me.

        D Offline
        D Offline
        developerit
        wrote on last edited by
        #3

        iam using this query but not getting the proper result. select companyname,branchname,location from users,company,branch on user.companyid=company.companyid innerjoin company.companyid=branch.branchid i want the user blongs to the company and all related branches can you suggest.

        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