problem 1:
move the WHERE clauses to the ON clauses

problem 2:
Obviously your intent with " COUNT( " is to count the
number of non-null occurences of click. But COUNT() is not the appropriate
function to do this (it will simply give you the number of rows inside a

Try replacing COUNT( by SUM( IF( IS
NULL, 0, 1 ) )

----- Original Message -----
From: "Lisi" <[EMAIL PROTECTED]>
Sent: Thursday, January 09, 2003 10:44 AM
Subject: [PHP-DB] LEFT JOIN not working

> I have a page with many ads that stores both the number of times an ad is
> displayed and how many times it gets clicked.  These are stored in two
> different tables (since different information is stored for each) but both
> have identical name columns. I am trying to display both # times displayed
> and # times clicked in the same table in an admin page.
> Here is my query:
> SELECT,, SUM(ads_displayrate.count)
> as display, COUNT( as click FROM ads_displayrate LEFT
> JOIN ads_clickrate ON = WHERE
> YEAR( = '2003' AND MONTH( = '01'
> I want to display for each ad the number of times displayed, and then
> number of times clicked if applicable, if not 0.
> The query is only returning rows for ads that have been clicked on. Is the
> problem because I have a COUNT column for one table, with a group by? Is
> this causing the display to be grouped also?
> If you need more information how the table is set up let me know, I'm
> really stumped here.
> Thanks,
> -Lisi
> --
> PHP Database Mailing List (
> To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to