![](/img/trans.png)
[英]How to get two id data from same table using codeigniter join funtion
[英]how to get data NO ID with join table in codeigniter?
我的数据将有一个数字键,该数字键如何与另一个表相等,因此可以称为名称。 我想将数据(数字键)更改为其他表格中的文本。
我的桌子1:
+-----------------------+
| ID | Name | Category |
-------------------------
| 1 | Home | 21 |
| 2 | Pro | 23 |
+-----------------------+
和表2:
+---------------------+
| ID | name_category |
-----------------------
| 21 | Sweet Home |
| 23 | your Home |
+---------------------+
如何获得相同的ID? 但数据将显示在表1中
尝试像this.Use join
上table1.ID = table2.ID
.displays的所有数据table1
从类别名称table2
匹配的表1 category ID
。
$this->db->select(*)
->from('table1')
->join('table2', 'table1.ID = table2.ID');
$result = $this->db->get()->result_array();
print_r($result);//displays all data of table1 with category names from table2 matching on table1 category ID.
$this->db->query('select table1.* from table1 inner join table2 on table1.id = table2.id');
$this->db->result();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.