我们如何在Active记录多个连接codeigniter

我们如何在Active记录多个连接codeigniter

本文介绍了我们如何在Active记录多个连接codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好球员可以请你帮我的上午初学者的数据库和codeigniter。我们如何写多内连接和左连接查询中的活动记录。

Hello guys can you please help me in as am beginner for Database and Codeigniter.How do we write this multiple inner join and left join query in active records.

SELECT suppliers.*, category.strCategory, category_1.strCategory AS strParent,
tblcitylist.city_name
FROM ((suppliers INNER JOIN category ON suppliers.intCat=Category.intId) INNER JOIN tblcitylist ON
suppliers.intCity=tblcitylist.city_id) LEFT JOIN category AS category_1 ON
category.intParent=Category_1.intId
WHERE status='y';

我有三个表供应商,tblcitylist和类别。想获取的数据具有intCat和intCity导致与供应商表与城市名称(CITY_NAME)和类名(strCategory)数据供应商。谢谢

I have three tables suppliers, tblcitylist and category. want to fetch data for supplier having intCat and intCity resulting with data of suppliers table with city name(city_name) and category name (strCategory).Thanks

推荐答案

也许这就是你追求的是什么...

Perhaps this is what you're after...

$query = $this->db->select('suppliers.*, category.strCategory, category_1.strCategory AS strParent, tblcitylist.city_name')
            ->from('suppliers')
            ->join('category',                  'suppliers.intCat=Category.intId',          'inner')
            ->join('tblcitylist',               'suppliers.intCity=tblcitylist.city_id',    'inner')
            ->join('category as `category_1',   'category.intParent=Category_1.intId',      'left')
            ->where('status','y')
                ->get();

CI DB文档: http://ellislab.com/codeigniter /用户指南/数据库/ index.html的

这篇关于我们如何在Active记录多个连接codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 19:58