Simple query problem
| From: | Shaun | Date: | Mon, 28 Apr 2003 18:56:32 +0000 |
| Subject: | Simple query problem | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27410@lists.php.net to get a copy of this message | ||
Hi,
How can i change the following query so that i only get unique Booking_ID's:
SELECT B.Booking_ID FROM WMS_Bookings B, WMS_Data D WHERE B.Booking_ID =
D.Booking_ID AND B.Project_ID = '17'
Here are the tables relating to this query:
# ---------- MySQL dump ----------
#
# Table structure for table 'WMS_Bookings'
#
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 ,
Rep_ID int(11) DEFAULT '0' NOT NULL ,
PCT_ID int(11) DEFAULT '0' NOT NULL ,
Practice_ID int(11) DEFAULT '0' NOT NULL ,
Booking_Start_Date date DEFAULT '0000-00-00' NOT NULL ,
Booking_End_Date date DEFAULT '0000-00-00' NOT NULL ,
Booking_Days int(11) DEFAULT '1' NOT NULL ,
Booking_Hours decimal(3,2) DEFAULT '0.00' NOT NULL ,
Booking_Mileage int(5) ,
Booking_Status int(2) DEFAULT '0' NOT NULL ,
Work_Type varchar(20) DEFAULT '' NOT NULL ,
Additional_Notes text ,
PRIMARY KEY (Booking_ID,User_ID,Project_ID,Rep_ID,PCT_ID)
);
#
# Table structure for table 'WMS_Data'
#
CREATE TABLE WMS_Data (
Data_ID int(11) DEFAULT '' NOT NULL auto_increment,
Data int(11) DEFAULT '0' NOT NULL ,
Field_ID int(11) DEFAULT '0' NOT NULL ,
Booking_ID int(11) DEFAULT '0' NOT NULL ,
PRIMARY KEY (Data_ID)
);
# ----------- Dump ends -----------
When i run the query i get the following result:
Booking_ID
45
45
47
47
Thanks for your help :)