mysql-5.0.41 moved back to ready
Radoslaw Zielinski
radek at pld-linux.org
Mon May 28 12:29:48 CEST 2007
Elan Ruusamäe <glen at delfi.ee> [25-05-2007 16:23]:
[...]
> mysql> select a.category_id,count(*) from album a where exists (select album_id from image where album_id=a.id) group by 1;
> Empty set (0.00 sec)
This query makes little sense and is not ANSI SQL compliant (category_id
not used in aggregate statement or GROUP BY), so both behaviours are
incorrect -- it should return an error.
If you want to count the number of albums in a given category which have
images, that would be the proper query (exists vs join: depending on the
amount of data):
select a.category_id, count(*)
from album a
join image i on i.album_id=a.id
group by a.category_id;
</offtopic>
--
Radosław Zieliński <radek at pld-linux.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /mailman/pipermail/pld-devel-en/attachments/20070528/4e66a00d/attachment.sig
More information about the pld-devel-en
mailing list