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. Multiple Join to the same field

Multiple Join to the same field

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

    Hi, i have the following code:

    SELECT visit_investigations.*,
    price_list_items.*,
    employee.employee_short_name as created_by
    FROM visit_investigations
    INNER JOIN price_list_items ON price_list_items.item_id = visit_investigations.item_id
    INNER JOIN employee ON visit_investigations.created_user = employee.employee_number
    WHERE visit_investigation_id = param_visit_investigation_id;

    where created by is the employee created the record andit will never be blank. I want to add the field visit_investigations.result_by for the user who submited the result. this will be a number representing the employee.employee_number and it might be blank for records without result yet. How can I do this?

    Technology News @ www.JassimRahma.com

    D M 2 Replies Last reply
    0
    • J Jassim Rahma

      Hi, i have the following code:

      SELECT visit_investigations.*,
      price_list_items.*,
      employee.employee_short_name as created_by
      FROM visit_investigations
      INNER JOIN price_list_items ON price_list_items.item_id = visit_investigations.item_id
      INNER JOIN employee ON visit_investigations.created_user = employee.employee_number
      WHERE visit_investigation_id = param_visit_investigation_id;

      where created by is the employee created the record andit will never be blank. I want to add the field visit_investigations.result_by for the user who submited the result. this will be a number representing the employee.employee_number and it might be blank for records without result yet. How can I do this?

      Technology News @ www.JassimRahma.com

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      I beleve you want to join to the employee table more than once. It would be something like: INNER JOIN employee e1 ON visit_investigations.created_user = e1.employee_number INNER JOIN employee e2 ON = e2.employee_number Hope that helps. :cool:

      1 Reply Last reply
      0
      • J Jassim Rahma

        Hi, i have the following code:

        SELECT visit_investigations.*,
        price_list_items.*,
        employee.employee_short_name as created_by
        FROM visit_investigations
        INNER JOIN price_list_items ON price_list_items.item_id = visit_investigations.item_id
        INNER JOIN employee ON visit_investigations.created_user = employee.employee_number
        WHERE visit_investigation_id = param_visit_investigation_id;

        where created by is the employee created the record andit will never be blank. I want to add the field visit_investigations.result_by for the user who submited the result. this will be a number representing the employee.employee_number and it might be blank for records without result yet. How can I do this?

        Technology News @ www.JassimRahma.com

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

        As David has suggested you need a 2nd join to the employee table but make it a LEFT join if there are missing records.

        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