RE: [PHP] MySQL problem

From: Date: Wed, 04 Jul 2001 22:20:46 +0000
Subject: RE: [PHP] MySQL problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56236@lists.php.net to get a copy of this message
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 dread@texas.net -- 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.

« previous php.general (#56236) next »