Re: Simple query problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux