在where子句中按月选择记录 [英] Select records by month in where clause

查看:135
本文介绍了在where子句中按月选择记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按月查询资料

$this->db->select('vehicle_make_and_model');
$this->db->join('tukai_drivers','tukai_drivers.driver_id=reqn_challans.dc_driver_id','left');
$this->db->where('dc_challan_date','MONTH(2)');
$this->db->order_by('dc_challan_id','desc');
$result=$this->db->get('reqn_challans')->result();

我通过这样的代码指令尝试

I am trying it via codeignitor like this

$this->db->where('dc_challan_date','MONTH(2)');

它没有工作?错误

以这种方式储存日期

http://awesomescreenshot.com/0424q72ne5

推荐答案

您需要更新您的where条件从

You need to update your where condition from

$this->db->where('dc_challan_date','MONTH(2)');

$this->db->where('MONTH(dc_challan_date)','2');

实际的函数是 MONTH(date)所以这里你有 MONTH(dc_challan_date)这是你的列名

The actual function is like MONTH(date) so here you have MONTH(dc_challan_date) which is your column name

这篇关于在where子句中按月选择记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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