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

  • Home
  • SEARCH
  • 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 7043265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:16:05+00:00 2026-05-28T02:16:05+00:00

I have three tables in MSSQL for a game which are structured as follows:

  • 0

I have three tables in MSSQL for a game which are structured as follows:

CHARS
This is the look up table it has:

  • strAccount which is linked to the primary key of NGSCUSER it is the
    account username
  • strChar01 which is the first character slot
  • strChar02 which is the second character slot
  • strChar03 which is the third character slot

these have the primary key of the gameuser table inside they are character names

NGSCUSER

  • strUserID account username
  • strPasswd account password

GAMEUSER

  • strUserId this is the character name
  • sRank whether the character is a game master

What I need to be able to do in is compare the login details against the PHP variables $username and $password in the query and most importantly check their associated character and find out whether it has a sRank of 1

I assume I need a three table join of some kind but I don’t know how to go about it any examples or help would be much appreciated

This is the query I’ve tried to build so far but it errors on the third line with incorrect syntax near ‘CHARS’:

SELECT NGSCUSER.strUserID, NGSCUSER.strPasswd, GAMEUSER.sRank 

FROM 'CHARS'

INNER JOIN NGSCUSER ON NGSCUSER.strUserId = CHARS.strAccount
INNER JOIN GAMEUSER ON GAMEUSER.strUserId = CHARS.strChar01
INNER JOIN GAMEUSER ON GAMEUSER.strUserId = CHARS.strChar02
INNER JOIN GAMEUSER ON GAMEUSER.strUserId = CHARS.strChar03


WHERE NGSCUSER.strUserId='$username' and NGSCUSER.strPasswd='$password' and GAMEUSER.sRank = '1'
  • 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-05-28T02:16:06+00:00Added an answer on May 28, 2026 at 2:16 am

    Firstly, to literally answer your question (which probably doesn’t solve your problem), you need to alias your tables to join multiple tables:

    select * from [chars] c
    inner join ngscuser n on n.strUserId = c.strAccount
    inner join gameuser g1 on g1.strUserId = c.strChar01
    inner join gameuser g2 on g2.strUserId = c.strChar02
    inner join gameuser g3 on g3.strUserId = c.strChar03
    where n.strUserId='$username' and n.strPasswd='$password' and g1.sRank = '1'
    

    However, if you’re trying to pull back the gameuser row that matches any character slot, then you need to use in:

    select n.strUserID, n.strPasswd, g.sRank 
    from [chars] c
    inner join ngscuser n on n.strUserId = c.strAccount
    inner join gameuser g on g.strUserId in (c.strChar01, c.strChar02, c.strChar03)
    where n.strUserId='$username' and n.strPasswd='$password' and g.sRank = '1'
    

    And, now that I have your attention, I would like to do the following PSAs:

    1. I hope you’re sanitizing $username and $password so that you are not susceptible to SQL injection.
    2. Do not store passwords in plaintext. You should only be storing them as salted hashes. If you can do a select * from ngscuser and get everybody’s password, shame on you. Shame. Shame. Shame.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL Left Join problem. I have three tables which I'm trying
I have a MySQL query that: gets data from three tables linked by unique
I have a mysql table with three columns: username, location, timestamp. This is basically
I have a database that has two tables, one of which contains a foreign
I have two tables that pertain to this part of a trivia quiz game:
I have three tables in mysql which have full text search enabled: title (title,
I have 3 tables that look something like this: Table1 Users: ID Name Score
I have three tables one of this storing users basic information, the other one
I have three tables: categories, languages and categories_languages. Categories_languages is many to many table
I have three mysql tables items =========== id title items_in_categories ============================ id item_id category_id

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.