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. how can left join two table on multiple column???

how can left join two table on multiple column???

Scheduled Pinned Locked Moved Database
question
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.
  • M Offline
    M Offline
    mhd sbt
    wrote on last edited by
    #1

    hi to all i have two table same below : tableA with this columns: ID CodeGuid Name Family --------------------- and tableB with this columns: ID CodeGuid mycomulns ---------------------------- i want to left join this two table on ID and CodeGuid but i dont want use code same this: select * from tableA Left JOIN tableB on (tableA.ID = tableB.ID) UNION select * from tableA Left JOIN tableB on (tableA.CodeGuid= tableB.CodeGuid) ---------------------------- is there another way to handle this output ? thanks in advance

    Richard DeemingR 1 Reply Last reply
    0
    • M mhd sbt

      hi to all i have two table same below : tableA with this columns: ID CodeGuid Name Family --------------------- and tableB with this columns: ID CodeGuid mycomulns ---------------------------- i want to left join this two table on ID and CodeGuid but i dont want use code same this: select * from tableA Left JOIN tableB on (tableA.ID = tableB.ID) UNION select * from tableA Left JOIN tableB on (tableA.CodeGuid= tableB.CodeGuid) ---------------------------- is there another way to handle this output ? thanks in advance

      Richard DeemingR Online
      Richard DeemingR Online
      Richard Deeming
      wrote on last edited by
      #2

      If both columns must match:

      SELECT
      ...
      FROM
      tableA
      LEFT JOIN tableB
      ON tableA.ID = tableB.ID
      AND tableA.CodeGuid = tableB.CodeGuid

      If either column can match:

      SELECT
      ...
      FROM
      tableA
      LEFT JOIN tableB
      ON tableA.ID = tableB.ID
      OR tableA.CodeGuid = tableB.CodeGuid


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      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