Re: Simple query problem
| From: | Ignatius Reilly | Date: | Mon, 28 Apr 2003 18:58:30 +0000 |
| Subject: | Re: Simple query problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27411@lists.php.net to get a copy of this message | ||
SELECT DISTINCT B.Booking_ID etc.
Ignatius
____________________________________________
----- Original Message -----
From: "Shaun" <shaun@mania.plus.com>
To: <php-db@lists.php.net>
Sent: Monday, April 28, 2003 8:56 PM
Subject: [PHP-DB] Simple query problem
> 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 :)
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>