Please help me to fix my SELECT clause.
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 and employee id is foreign key to people table.
After joining tables, I want to display in HTML the inventory table, but instead of displaying the employee id, I want the employee NAME to be displayed.
I was able to display only the last name of the employee with this code:
$this->db->select('inventory.*, items.name ,people.last_name');
$this->db->from('inventory');
$this->db->join('items', 'inventory.trans_items = items.item_id' , 'left');
$this->db->join('people', 'inventory.trans_user = people.person_id' , 'left');
$this->db->where('deleted', 0);
$this->db->order_by('trans_date desc');
but I need it to be first name and last name so I did this:
$this->db->select('inventory.*, items.name ,CONCAT(people.first_name, " ",people.last_name) as employee');
$this->db->from('inventory');
$this->db->join('items', 'inventory.trans_items = items.item_id' , 'left');
$this->db->join('people', 'inventory.trans_user = people.person_id' , 'left');
$this->db->where('deleted', 0);
$this->db->order_by('trans_date desc');
However, it errors when I use the CONCAT() function.