php - How do I write this mysqli query using joining multiple tables? -


i have hard time writing queries when need join multiple tables 1 result set.

i have 3 tables this:

store_stock:

id   itemweavetype   itemmodel   cost   price    7    3               4           10.00  15.00 

store_item_weaves:

id   weaveid 3    mc 

store_item_models:

id   modelid 4    hv 

i trying query gather of data item stock id of 7. finished result, array like:

array ( [id] => 7 [itemweavetype] => mc [itemmodel] => hv [cost] => 10.00 [price] => 15.00) 

so, need join data tables store_item_weaves , store_item_models.

a hastily put query - might work....

select * `store_stock` s left outer join `store_item_weaves` w on w.`id`=s.`itemweavetype` left outer join `store_item_models` m on m.`id`=s.`itemmodel` s.`id`=7; 

you select desired fields rather use * ~ ie:

select s.`id`, s.`price`, m.`modelid` etc etc 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -