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

SQL

Scheduled Pinned Locked Moved Database
databasehelpcareer
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.
  • R Offline
    R Offline
    Robert1974
    wrote on last edited by
    #1

    I'm in need of some sql help SELECT P1.name, P2.name , J.text FROM person p1, person p2, job J WHERE P1.persID = J.creatorID AND P2.persID = J.responsibleID AND J.id = 1 the above statement does not return any rows if the job J has null in the responsible field. But I want it to return an empty string for P2.name in that case. Is that possible. Would be thankful for any help!

    F 1 Reply Last reply
    0
    • R Robert1974

      I'm in need of some sql help SELECT P1.name, P2.name , J.text FROM person p1, person p2, job J WHERE P1.persID = J.creatorID AND P2.persID = J.responsibleID AND J.id = 1 the above statement does not return any rows if the job J has null in the responsible field. But I want it to return an empty string for P2.name in that case. Is that possible. Would be thankful for any help!

      F Offline
      F Offline
      Farhan Noor Qureshi
      wrote on last edited by
      #2

      You need an OUTER join. Start with this query. SELECT p1.name as p1name, isNULL(p2.name, '') as p2name , J.text FROM person p1 INNER JOIN job J ON p1.persID = J.creatorID LEFT OUTER JOIN person p2 ON J.responsibleID = p2.persID WHERE (J.id = 1) Farhan Noor Qureshi if (this == this) thow this;

      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