select * from active_listings
where open_date >= '$start_date'
AND open_date <='$end_date'
哪作得很好.
我在MysqL中有两列:open_date和next_open_date.如何执行包含open_date和next_open_date的范围子句.
我试过做:
select * from active_listings
where (open_date,next_open_date) >= '$start_date'
AND (open_date,next_open_date) <='$end_date')
我没有结果.
有人可以指导我或告诉我如何使用多列日期范围的方向.
谢谢!
解决方法:
为避免歧义,您必须将范围分开,如下所示:
select *
from active_listings
where (open_date >= '$start_date' AND open_date <='$end_date')
OR (next_open_date >= '$start_date' AND next_open_date <='$end_date');
或者,更短一些:
select *
from active_listings
WHERE open_date BETWEEN '$start_date' AND '$end_date'
OR next_open_date BETWEEN '$start_date' AND '$end_date';
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。