loading data from 2 tables in 1 query
#1

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);
Reply
#2

https://i.stack.imgur.com/qje6o.png

https://dev.mysql.com/doc/refman/5.7/en/join.html
Reply
#3

Код:
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)