SA-MP Forums Archive
Load 2 tables mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Load 2 tables mysql (/showthread.php?tid=657508)



Load 2 tables mysql - KinderClans - 09.08.2018

Hello, im using mysql to register/login account stats. Currently i have the table "players" which saves kills, score, money etc. etc. and each player has their unique account id (store in the table as well).

Since i don't like disorganized things, i created another table called "jobstats" which saves different job stats.

My question is:

Is possible to load jobstats table by using account id from players table to show job stats?

Currently i have this:

pawn Код:
mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
How i can make server select the jobstats table based on the account id of the player?


Re: Load 2 tables mysql - Banditul18 - 09.08.2018

Keyword: forgein keys


Re: Load 2 tables mysql - KinderClans - 09.08.2018

https://www.w3schools.com/sql/sql_foreignkey.asp

Got it. But how to use it?


Re: Load 2 tables mysql - Calisthenics - 10.08.2018

http://www.mysqltutorial.org/mysql-join/