RE: Selecting two names from a table

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

 



Hi,

Try something like this:

SELECT 	U1.User_Name
,		U2.User_Name
, 		B.Booking_Date 
FROM 		USER U1
,		USER U2
,		BOOKING B 
WHERE 	B.Booking_Creator = U1.User_ID 
AND 		B.Booked_User = U2.User_ID'

Jack



-----Original Message-----
From: Shaun [mailto:shaun@mania.plus.com] 
Sent: Monday, October 06, 2003 11:24 AM
To: php-db@lists.php.net
Subject:  Selecting two names from a table


Hi,

I have a table called Bookings and a table called User. Bookings are
created and hold the User_ID of the User who created it
(Booking.Booked_User) and the User who will be going on the booking
(Booking.Booking_Creator). How can I create a report that lists both
users on each row. If I do 'SELECT U.User_Name, B.Booking_Date FROM
WMS_User WHERE B.Booking_Creator = U.User_ID AND B.Booked_User =
U.User_ID', then the query returns no data. So for each row in the table
I need to somehow select 2 names from the user table based on 2
different User_ID's held in the Bookings table. Any help would be
greatly appreciated.


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