Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:12:23+00:00 2026-06-01T19:12:23+00:00

Table structure: users: uid, name friendships: uid1, uid2 game_membership: gid, uid basically I’m trying

  • 0

Table structure:

    users: uid, name
    friendships: uid1, uid2
    game_membership: gid, uid

basically I’m trying to get a query as a function of gid, and return:

uid1, name1, uid2, name2

where only the uid‘s that are in the game_membership table under the given gid are returned. this is what I’ve got so far:

SELECT 
   f.uid1 AS id1, 
   u1.name AS name1, 
   f.uid2 AS id2, 
   u2.name AS name2
FROM 
   friendships AS f
WHERE 
   u1.uid in (SELECT uid FROM game_membership WHERE gid = <GID>)
   AND u2.uid in (SELECT uid FROM game_membership WHERE gid = <GID>)
JOIN users AS u1 ON f.uid1 = u1.uid
JOIN users AS u2 ON f.uid2 = u2.uid

I just get a MySQL syntax error right now. Can anyone point me in the right direction? I feel like maybe I have to do another JOIN or two on the uid‘s in the game_membership table, one for each uid?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:12:24+00:00Added an answer on June 1, 2026 at 7:12 pm

    I would suggest you join to the Game_membership table instead of the where clause:

    SELECT 
       f.uid1 AS id1, 
       u1.name AS name1, 
       f.uid2 AS id2, 
       u2.name AS name2
    FROM 
       friendships AS f
    JOIN game_membership AS user1_gm ON user1_gm.uid = f.uid1
    JOIN game_membership AS user2_gm ON user2_gm.uid = f.uid2
    JOIN users AS u1 ON f.uid1 = u1.uid
    JOIN users AS u2 ON f.uid2 = u2.uid
    WHERE user1_gm.gid = <GID> AND user2_gm.gid = <GID>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following table structure: CREATE TABLE user ( uid INT(11) auto_increment, name VARCHAR(200),
This is my table structure fName Friend's Name [Varchar] fUID Friend's ID [Int] UID
I have this table structure: CREATE TABLE users ( uid bigint NOT NULL, first_name
I have the following table structure: Table Users ID | Name 1 | John
I have a users table with 450,000 records. The table structure is as so:
I have a MySQL table with the structure: beverages_log(id, users_id, beverages_id, timestamp) I'm trying
I have a table that contains articles posted by users. The structure of the
I've got three tables; Auctions, Auction Bids and Users. The table structure looks something
My MySQL tables structure (3 table) users id username images id user_id image user_follow
I have a table with such structure: uid sid all integers. This table simulates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.