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. many fields linked to one

many fields linked to one

Scheduled Pinned Locked Moved Database
questiondatabaselearning
2 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.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, i have the table lab_inestigations which has created_by, processed_by and closed_by and all three columns are integer holding a user id (systm_user_id) from a table sysem_users but of course each created_by, processed_by and closed_by will have different systm_user_id value.. How can I make such sql statement to rertive the system_user_name for all three columns from system_users? Thanks, Jassim

    M 1 Reply Last reply
    0
    • J Jassim Rahma

      Hi, i have the table lab_inestigations which has created_by, processed_by and closed_by and all three columns are integer holding a user id (systm_user_id) from a table sysem_users but of course each created_by, processed_by and closed_by will have different systm_user_id value.. How can I make such sql statement to rertive the system_user_name for all three columns from system_users? Thanks, Jassim

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

      You need to make 3 joins to the user table, one for each of your user fields in lab_inestigations, something like

      SELECT *
      FROM lab_inestigations I
      INNER JOIN sysem_users S1 ON SI.UserID = I.CreatedBy
      INNER JOIN sysem_users S2 ON S2.UserID = I.ProcessedBy
      INNER JOIN sysem_users S3 ON S3.UserID = I.ClosedBy

      Never underestimate the power of human stupidity RAH

      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