Re: [PHP] MySQL Left Join Question

2003-09-02 Thread Nicholas Robinson
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] MySQL Left Join Question

2003-09-01 Thread Van Andel, Robbert
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.aerialf
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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php