SQL
-
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!
-
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!
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;