>   Message   From   To
>   
>   Exampel      1       2
>
> UserID UserName
>    1         Me
>    2         You
> 
> Message   From   To
> Exampel    Me     You

SELECT 
  u.Message, u1.UserName AS From, u2.UserName AS To
FROM
  Messages AS m,
  Users    AS u1,
  Users    AS u2
WHERE
  m.From = u1.UserID AND
  m.To   = u2.UserID


Using aliases, you can reference the same table multiple times.

Jens

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