loading data from 2 tables in 1 query - 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: loading data from 2 tables in 1 query (
/showthread.php?tid=627170)
loading data from 2 tables in 1 query -
ax1 - 24.01.2017
this loads info from 1 mysql table
Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `info` WHERE `player` = '%e' LIMIT 1", name);
mysql_tquery(mysql, query, "Loading", "i", playerid);
and if I want to load info from other table (table name : "veh") as well should the code look like this?:
Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `info`, `veh` WHERE `player` = '%e' LIMIT 1", name);
mysql_tquery(mysql, query, "Loading", "i", playerid);
Re: loading data from 2 tables in 1 query -
Misiur - 24.01.2017
https://i.stack.imgur.com/qje6o.png
https://dev.mysql.com/doc/refman/5.7/en/join.html
Re: loading data from 2 tables in 1 query -
Vince - 24.01.2017
Код:
WHERE `player` = '%e'
I'm just going to be blunt: this is crap. Slow, inefficient and - if the tables aren't properly linked - prone to inconsistencies. You may have wondered why people add an "id" column to their tables. Well, this is why. Should the name ever change then that change has to be propagated throughout the entire database. An id never changes. Should the name change then that change is done in a single table and nothing else is affected.