i have one table products and one table locations. products table have two columns pickLocation and recLocation. in locations table i have id and name columns. pickLocation and recLocation have id from location table. how can i join table in codeigniter.
Here is my code
$this->db->select("locations.name as plname");
$this->db->select("locations.name as rcname");
$this->db->join("locations","locations.id=products.pickLocation","LEFT");
$this->db->join("locations","locations.id=products.recLocation","LEFT");
Here is Products table
+----+--------------+-------------+
| Id | pickLocation | recLocation |
+----+--------------+-------------+
| 1 | 12 | 23 |
| 2 | 12 | 12 |
+----+--------------+-------------+
Here is Location table
+----+-----------+--+
| Id | name | |
+----+-----------+--+
| 12 | Location1 | |
| 23 | Location2 | |
+----+-----------+--+
I want result like this
+-----------------------+
| 1 Location1 Location2 |
+-----------------------+
| 2 Location1 Location1 |
+-----------------------+