I did some checkin' in the documentation at mysql.com but from what they had, I can't figure out how to combine 2 "left joins" and 2 "counts". When displaying the output, both counts give me the same number and its incorrect.

Here's what I have for the query:

PHP Code:
$result mysql_query("SELECT ph.agent_id, ph.home_id,
    COUNT(ph.agent_id) as img_count,
    COUNT(homes.owner) as listings
    FROM home_photo ph

    LEFT JOIN homes ON (homes.owner = ph.agent_id)
    LEFT JOIN agents ON (agents.id = ph.agent_id)

    WHERE (ph.agent_id = '
$current_user')
    GROUP BY ph.agent_id;"
,$link);

while(
$row mysql_fetch_array($result)) {
    
extract($row);

So when displaying $img_count and $listings, they are the same.

Here's the main part of the "homes" table.

CREATE TABLE homes (
id int(11) DEFAULT '0' NOT NULL auto_increment,
owner int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
KEY owner (owner),
);

and the home_photo table:

CREATE TABLE home_photo (
id smallint(6) DEFAULT '0' NOT NULL auto_increment,
agent_id smallint(6) DEFAULT '0' NOT NULL,
home_id smallint(6) DEFAULT '0' NOT NULL,
PRIMARY KEY (id)
);

I'm not getting an error, just incorrect numbers.

Any ideas what I'm doing incorrectly as I can't seem to find the problem?

Thanks again!