I have 3 Tables With Following Structure!
Delivery_Boy : id(PK), date, time, comment, order_id,
Order_history : order_history_id(PK), order_id, order_status_id,
Order_status : order_status_id(PK), status_name
Requirement: Delivery_boy table contains orders each having unique order_id. But the order_status_id or Status_name is not Available in this Table.
I want to join the order_history and order_status table, so that they produce status_name for corresponding order_status_id and display it as a column in delivery_boy table.
Currently my Code is:
public function getOrder($username) {
$query = $this->db->query("SELECT date, time, oh.order_id, oh.comment, os.order_status_id AS status FROM delivery_boy oh LEFT JOIN ". DB_PREFIX . "order_history os ON oh.order_id = os.order_id WHERE name = '" . $this->db->escape($username) . "'");
return $query->rows;
}
And I get the result like in the below image: It only shows the status_id, not the status_name.