Jens Mildner wrote:

> Hello MySQL-users !
> 
> Houston, I've got a problem here.
> 
> I'm running the following query from a PHP-Script:
> 
> SELECT years.year AS yearlist, count(years.year) AS gamecount 
> 
> FROM years 
> 
> LEFT JOIN games 
> 
> ON years.year = games.release_year
> 
> GROUP BY years.year 
> 
> ORDER BY gamecount DESC, yearlist
> 
> 
> This query should do the following: 
> 
> Every year from years.year should be returned along with the 
> number of games that have been released in that year sorted by 
> the gamecount.
> years.year and games.release_year both do NOT contain NULL.
> 
> The problem is the following:
> 
> Years in which no games were released are returned with a 
> gamecount of 1. Why that??? All other years with games released 
> in it are getting the correct gamecount.
> 
> Please help me.
> 
> Greetings from Germany, Jens Mildner.

Either don't  use a left join, or add  "WHERE games.release_year IS NOT 
NULL"


> 


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to