Help with PHP MySQL join
Posted
by
kester martinez
on Stack Overflow
See other posts from Stack Overflow
or by kester martinez
Published on 2011-01-06T05:29:09Z
Indexed on
2011/01/06
5:54 UTC
Read the original article
Hit count: 191
Please help me to understand proper join syntax.
I have table named inventory which has:
trans_id
trans_items items -> item_id
trans_user employees -> person_id
trans_date
trans_comment
trans_inventory
As you can see above, trans_items is a foreign key in items table, and trans_user is a foreign key in employees table.
Now what I want to do is to display in HTML the inventory table, but instead of displaying the item id, I want the ITEM NAME to be displayed.
Here is what I have done. Please note I'm using CodeIgniter.
public function getData(array $inputs)
{
$this->db->select('trans_items, trans_user, trans_date, trans_inventory, trans_comment');
$this->db->from('inventory');
$this->db->order_by('trans_date desc');
return $this->db->get()->result_array();
}
© Stack Overflow or respective owner