Codeigniter连接查询多个条件不起作用 [英] Codeigniter join query multiple conditions don't work

查看:128
本文介绍了Codeigniter连接查询多个条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过连接查询从数据库表中选择数据,但是我无法使用.

I want to select data from my database table with join query, but my it doesn't work.

我的查询:

$this->db->select();
$this->db->from('we');
$this->db->join('schedule', 'schedule.itemid = we.cid');
$this->db->join('schedule', 'schedule.itemtype = 'testitem'');
$this->db->where('we.isActive','Y');

此行使schedule.itemtype = 'testitem'出现问题:

 $this->db->join('schedule', 'schedule.itemtype = 'testitem'');

我该如何解决?

推荐答案

您不需要两次连接同一张表. 但是只是为了扩展ON子句:

You don't need to join same table twice. But just to extend ON clause:

$this->db->select();
$this->db->from('we');
$this->db->join('schedule', 'schedule.itemid = we.cid AND schedule.itemtype = \'testitem\'');
$this->db->where('we.isActive','Y');

这篇关于Codeigniter连接查询多个条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆