How to 'link' the two ids?
#1

Okay, I've got vID save in the player table and a vID in the vehicles table on MySQL..

How would I 'link' these both for a player to know it's his car?
Reply
#2

And that is?
Reply
#3

Use joins.

PHP код:
SELECT *
FROM usertable JOIN vehicletable
    ON usertable
.vID vehicletable.vID 
This will return all players that have a vehicle. If you want all players, even those who don't have a vehicle use LEFT JOIN.

PHP код:
SELECT *
FROM usertable LEFT JOIN vehicletable
    ON usertable
.vID vehicletable.vID 
Documentation: http://www.w3schools.com/sql/sql_join.asp
Reply
#4

Lolwut?

I honestly don't get what you just said.

EDIT: I get this error.
No database selected

And I've got this.

Код:
SELECT * 
FROM players JOIN vehicles
    ON players.vehicleID = vehicles.vID
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
Foreign keys.
!!
http://dev.mysql.com/doc/refman/5.1/...nstraints.html
Reply
#6

Is this it?

Reply
#7

Yes, I read this one:
http://dev.mysql.com/doc/refman/5.1/...nstraints.html

But, is that what it is in the picture above?
Reply
#8

I didn't use the GUI. I went into Player > Structure > Relation View > Here.
Reply
#9

That would be you using the GUI.

Regardless, find the section of the program you are using to navigate through your database that you can execute code from. Make changes to the table using the code from that documentation, as appropriate.
Reply
#10

I've tried doing it the other way and it doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)