php - Using LEFT OUTER JOIN to build query results -


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

here have far:

$query = $db->query("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"); 

this returns array like:

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

so, i'm there. instead of using values of weaveid , modelid itemweavetype , itemmodel, adding onto array.

any ideas?

use columns list instead of * make sure values want:

$query = $db->query("select s.id, w.weaveid, m.modelid, s.cost, s.price `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"); 

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 -