简体   繁体   English

在codeigniter中加入两个以上的表

[英]Join more than two tables in codeigniter

I have 4 tables and i want to join there tables together in codeigniter. 我有4个表,我想在codeigniter中一起加入那些表。 Is it possible with codeigniters join method? 是否可以使用codeigniters加入方法?

If you are using CodeIgniter's Active Record class, you can just use the join method multiple times to join multiple tables. 如果您正在使用CodeIgniter的Active Record类,则可以多次使用join方法来连接多个表。

$this->db->join('table2', 'table2.ID = table1.ID');
$this->db->join('table3', 'table3.ID = table1.ID');
$this->db->join('table4', 'table4.ID = table1.ID', 'left');

I assume that you are talking about joining SQL database tables, is this correct? 我假设您正在谈论加入SQL数据库表,这是正确的吗? If so you can always use the CodeIgniter SQL method, see: http://codeigniter.com/user_guide/database/queries.html 如果是这样,您始终可以使用CodeIgniter SQL方法,请参阅: http//codeigniter.com/user_guide/database/queries.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM