How to select foreign key
#1

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

What MySQL version are you using?
Reply
#3

Last..
R41-4 from BlueG
Reply
#4

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!
Reply
#5

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
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)