List:General Discussion« Previous MessageNext Message »
From:Chris Date:May 20 1999 8:54pm
Subject:SQL Question...
View as plain text  
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?

--Chris

Thread
SQL Question...Chris21 May
  • Re: SQL Question...Benjamin Pflugmann21 May