我必须查询具有 where 条件的东西,>=
但=<
我没有运气。这是在CODEIGNITER中。
这是mysql查询中的自然方式:
SELECT COUNT(payment.keyid) AS rec_count, `product_key`.`client_name`,
`product_key`.`contact_email`, `product_key`.`status`, `product_key`.`id`,
`payment`.`paymentdate`, (payment.id) as pid, `payment`.`subscription_type`
FROM (`product_key`)
LEFT OUTER JOIN `payment` ON `payment`.`keyid`=`product_key`.`id`
WHERE `payment`.`paymentdate` >= '2013-08-01'
AND `payment`.`paymentdate` =< '2013-08-31'
AND `status` = 'purchased'
GROUP BY `product_key`.`id`
ORDER BY `client_name` asc
这就是我所拥有的:
return $this->db
->select('COUNT(payment.keyid) AS rec_count')
->select('product_key.client_name, product_key.contact_email, product_key.status, product_key.id, payment.paymentdate, (payment.id) as pid,payment.subscription_type')
->from('product_key')
->where('payment.paymentdate >=', $month_start)
->where('payment.paymentdate =<', $month_end)
->where('status', 'purchased')
->join('payment', 'payment.keyid=product_key.id', 'left outer')
->order_by('client_name', "asc")
->group_by('product_key.id')
->get()
->result();
也许有人可以帮助我。谢谢。