Tacomon
05-07-2006, 12:51 AM
Here's my two tables with the relevant fields
TABLE 1: user_id | user_name
TABLE 2: event_id | event_winner (a user_id from Table 1) | event_loser (a user_id from Table 1)
I would like to do a query with the information needed to output the last ten events and the names of the winners and losers. Trying:
SELECT table1.user_name, table2.event_winner, table2.event_loser
FROM table1
INNER JOIN table2
ON table1.user_id = table2.event_winner
OR table1.user_id = table2.event_winner
This partly did what I wanted, but separated the winner on one line and the loser on the next line of the results. Adding GROUP BY alleviates this, but gets rid of one of the names.
How do I get both the winner and loser's name on the same line of results? Thanks for any help. :)
TABLE 1: user_id | user_name
TABLE 2: event_id | event_winner (a user_id from Table 1) | event_loser (a user_id from Table 1)
I would like to do a query with the information needed to output the last ten events and the names of the winners and losers. Trying:
SELECT table1.user_name, table2.event_winner, table2.event_loser
FROM table1
INNER JOIN table2
ON table1.user_id = table2.event_winner
OR table1.user_id = table2.event_winner
This partly did what I wanted, but separated the winner on one line and the loser on the next line of the results. Adding GROUP BY alleviates this, but gets rid of one of the names.
How do I get both the winner and loser's name on the same line of results? Thanks for any help. :)