
Originally Posted by
Jaipai
Though I want to join the user table to obtain information for both users.
this is a common issue
you will have to join to the users table twice, once for each user id
you need table aliases, to distinguish between the two copies of the table, and also column aliases, to distinguish which column belongs with which user
Code:
SELECT events.event_type
, user1.avatar AS user1_avatar
, user2.avatar AS user2_avatar
FROM events
INNER
JOIN users AS user1
ON user1.profile = events.user1
INNER
JOIN users AS user2
ON user2.profile = events.user2
WHERE $id IN ( events.user1 , events.user2 )
Bookmarks