php - 如何使用 CodeIgniter INNER JOIN 3 个表

标签 php mysql codeigniter

谁能告诉我如何用 php 连接 3 个表? 示例

SELECT FROM table1, table2,table on INNERJOIN -------------------

让我有 3 个表。(问题表,答案表和类别表) 这是我的网页示例。

Time remaining 30 minutes(I will get "30 minutes" form Category table)
1. Question (from question table)
2. answer (from answer table)

我不知道如何加入 3 表。

最佳答案

应该是这样的

$this->db->select('*');    
$this->db->from('table1');
$this->db->join('table2', 'table1.id = table2.id');
$this->db->join('table3', 'table1.id = table3.id');
$query = $this->db->get();

根据 CodeIgniters 事件记录框架

关于php - 如何使用 CodeIgniter INNER JOIN 3 个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7440371/

相关文章:

php - 如何将数组从php文件导出到另一个php文件

php - mysql结果只能看到好友id

mysql - 邮件列表的数据库结构

mysql - 如何在 MySQL SELECT 结果集中包含自定义计数?

codeigniter 基准 {memory_usage} 安全

php - Mysql 连接多列

php - 如何将 Base64 PNG 转换为 JPG 图像?

php - 如何使用 javascript 和 php 更改 php 读取文件。新Q如何阻止它影响标题

php - SoundCloud 如何让 favicon 在按下播放按钮时动态变化?

php - 向 config/database.php 中的表添加前缀,但有一些异常(exception)