4 messages in com.mysql.lists.bugsLEFT JOIN with GROUP BY report only f...
FromSent OnAttachments
Alex Villacís Lasso30 Nov 2001 08:49 
Ord Millar03 Dec 2001 10:07 
Michael Widenius03 Dec 2001 20:28 
Michael Widenius05 Dec 2001 13:57 
Subject:LEFT JOIN with GROUP BY report only first row of query with empty right table.
From:Michael Widenius (mon@mysql.com)
Date:12/03/2001 08:28:23 PM
List:com.mysql.lists.bugs

Hi!

"avillaci" == avillaci <Alex> writes:

avillaci> Description: avillaci> When a query is made in the form: avillaci> select table_a.name, sum(table_b.value) as sum_values from table_a
left avillaci> join table_b on table_a.a_key = table_b.a_key group by table_b.a_key avillaci> and table_b happens to be empty, the result set incorrectly contains
only the avillaci> first row of table_a. It should contain at least as many rows as there
are on avillaci> table_a, with the group function (in this case, 'sum()'), evaluated to
the avillaci> appropriate value for a NULL field.

avillaci> How-To-Repeat: avillaci> The following script demonstrates the bug:

Thanks for the test case; I was able to repeat the bug and I will try to create a patch for this tomorrow.

Regards, Monty