2 messages in com.mysql.lists.mysqlSQL Question...
FromSent OnAttachments
Chris20 May 1999 13:54 
Benjamin Pflugmann20 May 1999 22:44 
Subject:SQL Question...
From:Chris (chr@hiro.studentadvantage.com)
Date:05/20/1999 01:54:18 PM
List:com.mysql.lists.mysql

Hi I have the following tables in my database:

category: id smallint(5) name varchar(25)

image: id smallint(5) category_key smallint(5) description varchar(25)

sound: id smallint(5) category_key smallint(5) description varchar(25)

The 'image' and 'sound' tables contain keys which correspond to the 'id' field in the 'category' table. I would like to be able to get a listing by category of the number of images and sounds that correspond to it. Something like this:

+-----------------------------------+ |Category | SoundCount | ImageCount | +-----------------------------------+ |cat1 | 4 | 3 | |cat2 | 0 | 1 | |cat3 | 1 | 0 | |cat4 | 0 | 0 | +-----------------------------------+

Is this possible with a single SQL query?