Ask coding questions

← Back to all posts
Help with joining SQL tables
amambro (1)


I haven't done much with SQL but I really want to learn and I am practicing with this little summer project of mine. I am really new to this so I am sorry my question might be simple to many out there, I am using my stay-at-home time to try and better myself! ^-^

I am trying to create a database for a video game my boyfriend plays. It is a very intense open world survival game where he was multiple characters. I am trying to help him keep track of all of his loot on all of his characters.

I created a new table for each character with information on the characters name, their location, some specific loot he might have etc. Right now I am up to 14 different characters, so 14 different tables.

I am super confused and stuck on how to organize it to where I can search all the characters at once, instead of having a search statement 14 different times. For example I might want to see all the characters names with their location and their hunger level. I think of it as like a master list but I am stuck as to how to make it work in SQL.

I've made a primary key for all the tables just with a simple userID that increments ++. I was thinking that I could made another table and put all of the primary keys in there, making them forgien keys, but I think then if I search the table its just going to give me the primary keys, not the data within those tables.

Im kinda losing my mind cause I know there is definitely an easy fix, I am just not that good at SQL yet. Any information or advice on what I should do is VERY much appreciated!!

Thank you!

ps. I didn't want to add the whole SQL file that I have so I have another file of just two tables that I copied with less data inputs to make it smaller.

Codejira (173)

There's a misunderstanding of how a database works. It collects data of the same kind in one table.

Think of a table as one spreadsheet in Excel. You organize your data columnwise with column headers like ID or name. Each row has a complete set of one data item then.

For your purpose you create one table named "player", then insert 14 rows of player's info into it. Then you are able to query your database, e.g. "who is where": SELECT name, location FROM player

SQL is a relational database. Its power lies in connecting related tables. You could enter info about all locations in a second table and refer to it by its ID.

There's so much more to say. For now let me point you to