简体   繁体   English

CodeIgniter:where子句中的case

[英]CodeIgniter: Case in where clause

How do we state the case in where clause condition in CodeIgniter's active record? 我们如何在CodeIgniter的活动记录中的where子句条件中陈述case

Here is the query I want to achieve 这是我想要实现的查询

SELECT * FROM table WHERE idx =5342 and CASE WHEN reserve_date = 20151130 THEN reserve_time > 1537 ELSE reserve_date > 20151130 END

I tried to search on Google about this question but still could not find any answer. 我试图在谷歌上搜索这个问题,但仍然找不到任何答案。

You can write your condition in where clause 你可以在where clause写下你的条件

$this->db->select("*");
$this->db->where("idx",5342);
$this->db->where("CASE WHEN reserve_date = 20151130 THEN reserve_time > 1537 ELSE reserve_date > 20151130 END");
$query=$this->db->get("table");

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

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