Re: MySQL Left Join Question

From: Date: Tue, 02 Sep 2003 04:04:25 +0000
Subject: Re: MySQL Left Join Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161412@lists.php.net to get a copy of this message
I'm not clear whether you are saying you get the records where there is a match and no non-matching records, or simply no records at all! What happens if you take out the WHERE clause, do you get all the records from p being displayed with NULLs for c.projectid where no match exists? Nick On Monday 01 Sep 2003 11:00 pm, Van Andel, Robbert wrote: > This may not be the best place to ask this question, but I'm running into a > problem when I perform a left join sql statement in PHP. The sql statement > is as follows: > > SELECT p.id > pid,p.designID,p.project_name,p.node,p.received,p.lots,p.ugfootage,p.aerial >f ootage,p.node,c.* FROM projects as p LEFT JOIN proSub as c on > p.id=c.projectID WHERE p.id=$id > > I have verified that $id has a value. What I'm finding is that when there > is no corresponding entry in proSub, the query returns nothing even though > LEFT JOIN is supposed to return the contents of the left table even if the > right table has no data. The left data does have data and I am asking for > the correct value for p.id. I've run into some other scripts on my site > where left join does not behave the way it's supposed to. > > Any thoughts?? > > Robbert van Andel

« previous php.general (#161412) next »