Help with PHP MySQL join
- by kester martinez
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();
}