On 04-Jul-01 Simon Kimber wrote:
> Hi All,
>
> Does anyone know if this can be done with one query?
>
> I have to create a chart based on info in two tables that are four tables
> apart.
>
> Here are the relevant tables and just the most relevant fields...
>
> accident_report
> - ID
> - weekending (this is a YYYY-MM-DD format date)
> - (and others)
>
> accident_data
> - ID
> - accident_report_id
> - (and others)
>
> accident_cause (a lookup table)
> - ID
> - accident_data_id
> - cause_id
>
> cause (a list of possible causes of accidents ie. "falling object" or
> "electric shock"
> - ID
> - Description
>
>
> I need to list all the causes with the number of times each has occurred,
> even if it's zero times... they don't need to be listed in any particular
> order...
>
"select cause.ID, count(*) as cnt from ...
WHERE ...
group by cause.ID";
Regards,
--
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]