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. Sql issue..

Sql issue..

Scheduled Pinned Locked Moved Database
databasehelptutorial
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.
  • T Offline
    T Offline
    Tash18
    wrote on last edited by
    #1

    I have 2 tables in my data base.. 1. User_Group table 2. Function_Group table Example: Function_Group table :

    Groupid Applicationid Functionid

    LCUser1 LCDocMgmt LC01
    LCUser2 LCDocMgmt LC02
    LCUser1 LCDocMgmt LC03
    LCUser3 LCDocMgmt LC04
    LCUser3 LCDocMgmt LC05
    LCUser2 LCDocMgmt LC06
    LCUser2 LCDocMgmt LC08
    LCUser1 LCDocMgmt LC09

    User_Group table:

    Userid Groupid

    900410 LCUser1
    900846 LCUser1
    900411 LCUser3

    Now i use the following query to retrieve the Groupid for a particular Userid : Select ug.groupid from User_Group ug, Function_Group fg where fg.ApplicationID='LCDocMgmt' and fg.GroupID = ug.GroupID and ug.UserID='900846' The result that i get on executing the above query is:

    groupid

    LCUser1
    LCUser1
    LCUser1

    Actually i Dont require repetition of records. If there is 2 distinct records i just want the 2 distinct records without repetition.. can any one plz help me.. Thanx in advance.... Regards, Tash

    J 1 Reply Last reply
    0
    • T Tash18

      I have 2 tables in my data base.. 1. User_Group table 2. Function_Group table Example: Function_Group table :

      Groupid Applicationid Functionid

      LCUser1 LCDocMgmt LC01
      LCUser2 LCDocMgmt LC02
      LCUser1 LCDocMgmt LC03
      LCUser3 LCDocMgmt LC04
      LCUser3 LCDocMgmt LC05
      LCUser2 LCDocMgmt LC06
      LCUser2 LCDocMgmt LC08
      LCUser1 LCDocMgmt LC09

      User_Group table:

      Userid Groupid

      900410 LCUser1
      900846 LCUser1
      900411 LCUser3

      Now i use the following query to retrieve the Groupid for a particular Userid : Select ug.groupid from User_Group ug, Function_Group fg where fg.ApplicationID='LCDocMgmt' and fg.GroupID = ug.GroupID and ug.UserID='900846' The result that i get on executing the above query is:

      groupid

      LCUser1
      LCUser1
      LCUser1

      Actually i Dont require repetition of records. If there is 2 distinct records i just want the 2 distinct records without repetition.. can any one plz help me.. Thanx in advance.... Regards, Tash

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      <> wrote:

      distinct records

      You answered your own question. Select DISTINCT ug.groupid from User_Group ug, Function_Group fg where fg.ApplicationID='LCDocMgmt' and fg.GroupID = ug.GroupID and ug.UserID='900846'

      T 1 Reply Last reply
      0
      • J J4amieC

        <> wrote:

        distinct records

        You answered your own question. Select DISTINCT ug.groupid from User_Group ug, Function_Group fg where fg.ApplicationID='LCDocMgmt' and fg.GroupID = ug.GroupID and ug.UserID='900846'

        T Offline
        T Offline
        Tash18
        wrote on last edited by
        #3

        Thanx alot... That was really a Dumb question from my side i knew that... Anyways a million thanx.. Regards, Tash

        J 1 Reply Last reply
        0
        • T Tash18

          Thanx alot... That was really a Dumb question from my side i knew that... Anyways a million thanx.. Regards, Tash

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          No problem. I also don't think it was particularly dumb compared to the general par.

          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