RE: [PHP-DB] Selecting two names from a table
| From: | Jacob A. van Zanen | Date: | Mon, 06 Oct 2003 11:02:10 +0000 |
| Subject: | RE: [PHP-DB] Selecting two names from a table | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30874@lists.php.net to get a copy of this message | ||
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: [PHP-DB] 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