Hi,

Does using an alias achieve what you want?

SELECT Inventory.*, p1.name, p2.name FROM
Inventory, People as p1, People as p2
where 
Inventory.in_possession = p1.person_id and
Inventory.returned_to = p2.person_id;

Regards

Quentin

-----Original Message-----
From: Cindy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 24 January 2001 13:32
To: [EMAIL PROTECTED]
Subject: question on select



OK, let's say I have two tables.  The first is a table
full of people -- their names, address, phone numbers.

The second table is an inventory, which among other things,
has a pointer to the first table for who currently has possession
of the item.

so I select from the two tables to print out an inventory list:

SELECT Inventory.*, People.name FROM Inventory, People WHERE
Inventory.in_possession = People.person_id

No problem.

BUT, I'd like to add something where it gives an option of who the item
in question was returned to.  Unfortunately, I'm not sure how to do
that?  Becasue Inventory.returned_to would also need to pull out from
the People table, but this could be a different person, and I don't
see how to assign that.  Would I have to create a temporary table to
do this or can it be done with a single select?

--Cindy

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

The information contained in this email is privileged and confidential
and intended for the addressee only. If you are not the intended 
recipient, you are asked to respect that confidentiality and not 
disclose, copy or make use of its contents. If received in error 
you are asked to destroy this email and contact the sender immediately. 
Your assistance is appreciated.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to