Help with a COUNT / SELECT query
| From: | Shaun | Date: | Fri, 23 Jan 2004 17:46:16 +0000 |
| Subject: | Help with a COUNT / SELECT query | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-32600@lists.php.net to get a copy of this message | ||
Hi,
I have a Bookings application. When a Booking is made it is entered in to
the Bookings table. Bookings take place at Areas, held in the Areas table.
Each Area has a unique Area_ID held in the Bookings table for each Booking.
Each Booking needs to be completed and when done so the Booking_Status for
each Booking is updated to '2'. An Area is complete when all Bookings at
that
Area have been completed. How can I run a query that tells me how many
completed Areas there are in the system?
Thanks for your help
CREATE TABLE WMS_Bookings (
Booking_ID int(11) DEFAULT '' NOT NULL auto_increment,
User_ID int(11) DEFAULT '0' NOT NULL ,
Project_ID int(11) DEFAULT '0' NOT NULL ,
Area_ID int(11) DEFAULT '0' NOT NULL ,
Booking_Start_Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL ,
Booking_End_Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL ,
Booking_Completion_Date date ,
Booking_Status int(2) DEFAULT '0' NOT NULL ,
Additional_Notes text ,
PRIMARY KEY (Booking_ID)
);
CREATE TABLE WMS_Area (
Area_ID int(11) DEFAULT '' NOT NULL auto_increment,
Area_Name varchar(40) DEFAULT '' NOT NULL ,
Area_Address varchar(255) DEFAULT '' NOT NULL ,
Area_Postcode varchar(10) DEFAULT '' NOT NULL ,
Area_Telephone varchar(15) DEFAULT '' NOT NULL ,
PRIMARY KEY (Area_ID)
);