我有以下内容:
with emp_mon as
(
select '101' emp_id, to_date('20190101','YYYYMMDD') month_of_project from dual
union all select '102', to_date('20190101','YYYYMMDD') from dual
union all select '103', to_date('20190101','YYYYMMDD') from dual
union all select '101', to_date('20190201','YYYYMMDD') from dual
union all select '104', to_date('20190301','YYYYMMDD') from dual
union all select '102', to_date('20190301','YYYYMMDD') from dual
union all select '105', to_date('20190401','YYYYMMDD') from dual
union all select '103', to_date('20190401','YYYYMMDD') from dual
),
mons as
(
select distinct month_of_project
from emp_mon
)
select mons.month_of_project, count(distinct emp_first_mon.emp_id) cnt_emp_id
from mons
left outer join
(
select emp_id, min(month_of_project) month_of_project
from emp_mon
group by emp_id
) emp_first_mon on emp_first_mon.month_of_project = mons.month_of_project
group by mons.month_of_project
order by 1
但是我收到以下信息:
/** Load necessary stuff **/
$this->load->helper('date');
$this->db->get('site_requests');
//echo mdate('%Y-%m-%d %H:%i:%s', now());
//die;
$this->db->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")");
$this->db->get();
print_r($this->db->last_query());
我在做什么错了?
答案 0 :(得分:1)
您可以将其放入一个语句中
$this->db->get_where('site_requests', array('created_for <=', '2019-04-24 18:47:03'));
print_r($this->db->last_query());
您将需要链接-> result()或result_array()或任何输出函数以获取数据返回。
希望这会有所帮助
答案 1 :(得分:0)
$this->db->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")");
应该在之后
$this->db->get('site_requests');
答案 2 :(得分:0)
尝试使用键值形式:
$this->db->where("created_for <=", "2019-04-24 18:47:03");
答案 3 :(得分:0)
您缺少定义查询的FROM
部分。
我认为您只需要更改代码即可:
$query = $this->db->from('site_requests')
->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")")
->get();
$result = $query->result();
print_r($result);