Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect the opposite row of a WHERE clause in a joined jquery result
    primarykey
    data
    text
    <p>I have a database with users and games. 1 game can have multiple users so I made a linking table called users_games. The crux is that a game can always only have 2 players since it is a board game. I know which player I am, i have my user_id and my email, but I would like to gain a result that gives me a list of all games I am in WITH the user_id and email of the other fellow. So a query that looks to all games I am in and give the other row, with the name of the player.</p> <p>My tables:</p> <p><strong>games</strong></p> <pre><code>id (int) board (varchar) representation of the board </code></pre> <p><strong>users</strong></p> <pre><code>id (int) email (varchar) password (varchar MD5) </code></pre> <p><strong>users_games</strong></p> <pre><code>id (int) user_id (int) game_id (int) </code></pre> <p>For clarification this query</p> <pre><code>SELECT * FROM `tic_users_games` AS ug LEFT JOIN tic_users AS u ON ug.user_id = u.id RIGHT JOIN tic_games AS g ON ug.game_id = g.id </code></pre> <p>And result</p> <pre><code>id user_id game_id id email password id board created updated 1 1 1 1 ME@gmail.com d56b699830e77ba53855679cb1d252da 1 0|0|0|0|0|0|0|0|0 2012-04-02 16:56:06 2012-04-02 16:56:06 2 2 1 2 FOE1@gmail.com d56b699830e77ba53855679cb1d252da 1 0|0|0|0|0|0|0|0|0 2012-04-02 16:56:06 2012-04-02 16:56:06 3 3 2 2 FOE2@gmail.com d56b699830e77ba53855679cb1d252da 2 0|0|0|0|0|0|0|0|0 2012-04-02 16:56:06 2012-04-02 16:56:06 4 1 2 1 ME@gmail.com d56b699830e77ba53855679cb1d252da 2 0|0|0|0|0|0|0|0|0 2012-04-02 16:56:06 2012-04-02 16:56:06 </code></pre> <p>See: In the above case I just want 2 rows: game_id 1 and 2, with FOE1@... and FOE2@...</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload