[eluser]tribalab[/eluser]
I'm trying to find the most effecient way to list messages sent to a user, but cross reference two tables to resolve userids that are used in the mail table with the names stores in the users table.
here are two simple tables:
USERS: [ ID, FIRSTNAME, LASTNAME ]
MAIL: [ TO, FROM, STATUS, SUBJECT, MESSAGE, DATE ];
The mail.to and mail.from are the respective users.id values. I'd like to do a single query to get all entries in mail where status='unread', but in addition to getting the id's for each message, I would like to get the users' firstname+" "+lastname as well.
So something like a combo of:
"SELECT * FROM mail WHERE mail.to=1" & foreach... "SELECT firstname, lastname FROM users WHERE id=".$mailfrom
Thanks for the help!
Aaron