MYSQL Query Help
You need foreign keys for this.
So I assume you have a user table like:
id | name | email
1 | John Smith | blah@gmail.com
2 | Jane Doe | hi@Test.com
So then you would have a ships table:
id | Name | Description
1 | Ship 1 | Awesome ship
2 | Ship 2 | Its massive
3 | Ship 3 | Kinda rubbish
Now finally you need a table to link a user to a ship. This allows you to create a 1 to many many to many relationship between users and ships:
id | fk_user_id | fk_ship_id
1 | 1 | 2
2 | 2 | 3
3 | 2 | 1
4 | 1 | 3
Now from these 3 tables you can see John owns ships 2 and 3 and Jane has ships 3 and 1. Whenever a person says they own a new ship an entry will be added to the last table

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now