How to select foreign key - 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: How to select foreign key (
/showthread.php?tid=657515)
[SOLVED] How to select foreign key -
GospodinX - 09.08.2018
Hi guys
I have two tables
1) inventory ( `ID` `userid` , `inv_item`(a item_name ID foreign key) , `inv_amount` )
2) item_name ( `ID` , `name` `weight` )
I have this query for example:
Код:
SELECT * FROM `inventory` WHERE `userid` = '2'
Result:
http://prntscr.com/kgp3tz
My question is: How to get item_name from this query(like in picture,how I can use it name in my script?)
Re: How to select foreign key -
Kraeror - 09.08.2018
What MySQL version are you using?
Re: How to select foreign key -
GospodinX - 09.08.2018
Last..
R41-4 from BlueG
Re: How to select foreign key -
Kraeror - 09.08.2018
You can use this Wiki
https://sampwiki.blast.hk/wiki/MySQL/R40...get_value_name (yeah, it's R40, but it's the same as the last one with a little differences)! You can get info using this functions: cache_get_value_name(for strings), cache_get_value_name_int (for integer), cache_is_value_name_null (for boolean) and cache_get_value_name_float (for float). You can check their parameters in the wiki I sent you!
Re: How to select foreign key -
Banditul18 - 09.08.2018
Quote:
Originally Posted by Kraeror
You can use this Wiki https://sampwiki.blast.hk/wiki/MySQL/R40...get_value_name (yeah, it's R40, but it's the same as the last one with a little differences)! You can get info using this functions: cache_get_value_name(for strings), cache_get_value_name_int (for integer), cache_is_value_name_null (for boolean) and cache_get_value_name_float (for float). You can check their parameters in the wiki I sent you!
|
He want to know how to build a query, not how to get the response
You need to use joins, g00gle about mysql joins and forgein keys and you will find what you need
Re: How to select foreign key -
GospodinX - 09.08.2018
Quote:
Originally Posted by Banditul18
He want to know how to build a query, not how to get the response
You need to use joins, g00gle about mysql joins and forgein keys and you will find what you need
|
Thanks..I didn't know much about joins...Solved.