我在clients表中有2列(还有更多列)。

conn_date     bill_date
=======================
2016-08-25    2016-09-04
2016-08-01    2016-09-03
2016-08-08    2016-09-01
2016-08-09    2016-09-01


现在,如果选择的月份是=(等于)或>大于conn_date,我想显示所有数据。我可以从html选择标签e中选择月份。 G。 :1,2,9

为此,我正在使用以下查询,但是它显示的数据少于conn_date

"SELECT cbp.advance_amount, cbp.bill_month, cbp.due_amount, cbp.pay_amount, c.is_active, c.client_id, c.user_id, c.address, c.contact_no, zone.zone_name, package.package_name, c.monthly_bill, c.bill_date FROM clients
AS c LEFT JOIN zone ON zone.zone_id = c.zone_id
LEFT JOIN package ON package.package_id = c.package_id
LEFT JOIN clients_pay_bill AS cbp ON cbp.client_id = c.client_id
WHERE c.uid = '$uid' AND c.is_active = 1
AND MONTH(c.conn_date) > $selected_month


使用print_r

SELECT cbp.advance_amount, cbp.bill_month, cbp.due_amount, cbp.pay_amount,
c.is_active, c.client_id, c.user_id, c.address, c.contact_no, zone.zone_name, package.package_name, c.monthly_bill, c.bill_date
FROM clients AS c
LEFT JOIN zone ON zone.zone_id = c.zone_id
LEFT JOIN package ON package.package_id = c.package_id
LEFT JOIN clients_pay_bill AS cbp ON cbp.client_id = c.client_id
WHERE c.uid = '6' AND c.is_active = 1
AND MONTH(c.conn_date) > 4 AND c.zone_id != ''
ORDER BY c.client_id DESC


所选月份图片

php - 如何显示大于或等于mysql表列月份的数据?-LMLPHP

最佳答案

基本上,我想显示的数据不小于所选月份的conn_date


的mysql查询是

SELECT * FROM clients WHERE MONTH(conn_date)<='".$selected_month."'

关于php - 如何显示大于或等于mysql表列月份的数据?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39204140/

10-16 14:55