在我的项目中,我想记录0-30天,30-60天,60-90天和90以上的记录。目前我获取0-30天的记录,如何从mysql数据库中获取其余的东西。我已在下面附上我的代码。我在codeigniter做我的项目。
public function outstandingMonth(){
$query = $this->db->query("SELECT * FROM zemco_tbl_invoice a left join zemco_tbl_payment b on (a.invoice_no=b.payment_invoice_id) WHERE invoice_status = 2 AND invoice_modified_time BETWEEN NOW() - INTERVAL 30 DAY AND NOW()");
}
任何人都可以帮我解决这个问题,提前谢谢
答案 0 :(得分:2)
这只是在不知道数据库的确切结构的情况下进行猜测,但是这不会成功吗?
<script type="text/javascript">
document.getElementById("instructor").onchange = function() {
document.getElementById("loading_input").style.display = "block";
document.getElementById("instructor").style.color = "#fff";
}
document.getElementById("subject_scheduling").onchange = function() {
document.getElementById("loading_input").style.display = "block";
document.getElementById("subject_scheduling").style.color = "#fff";
}
</script>
等等。
答案 1 :(得分:0)
如果您可以将days
范围间隔作为输入参数传递给函数,则可以在查询中使用它们来获取记录。
修改后的查询如下例所示:
SELECT * FROM zemco_tbl_invoice a
left join zemco_tbl_payment b on (a.invoice_no=b.payment_invoice_id)
WHERE invoice_status = 2
AND invoice_modified_time BETWEEN ( NOW() - INTERVAL $toDays DAY )
AND ( NOW() - INTERVAL $fromDays DAY )
如果您要在30到60天之间获取记录,则fromDays
为30
且toDays
为60.然后,上述查询结果如下:
SELECT * FROM zemco_tbl_invoice a
LEFT JOIN zemco_tbl_payment b ON a.invoice_no = b.payment_invoice_id
WHERE invoice_status = 2
AND invoice_modified_time BETWEEN ( NOW() - INTERVAL 60 DAY )
AND ( NOW() - INTERVAL 30 DAY )
您可以根据需要使用方法的输入参数,并根据需要在查询中使用。