At 08:31 23/10/2003 -0400, you wrote:
>I have two tables: tbl_user and tbl_news
>
>In the tbl_user table I have 3 columns (among others): userId, firstName,
>lastName
>
>In tbl_news I have two columns (among others): creatorId, updaterId both of
>which relate back to the tbl_user table.
>
>In a query, how would I get the first name and last name of both the creator
>and updater?
>
>I can JOIN and get one, but how to you differentiate between the creator and
>updater names when joining?

I think you need two table aliases for the same table:

SELECT u1.firstName AS creatorFirstName, u1.lastName AS creatorLastName,
u2.firstName AS updaterFirstName, u2.lastName AS updaterLastName
FROM tbl_user u1, tbl_user u2, tbl_news n
WHERE n.creatorId = u1.userId
AND n.updaterId = u2.userId

Not tested, but this should get you there :-)

Gyrus
[EMAIL PROTECTED]
http://norlonto.net/gyrus/dev/
PGP key available

[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to