【发布时间】:2009-05-06 05:50:42
【问题描述】:
我有一个 MySQL 数据库,其中有一个名为 ProductMaster 的表,其中包含 6 个字段“Product_Id、Product_Name、Model、Opening_date、Closing_Date、Status”。 Opening_Date 和 Closing Date 可以接受空值。所以有些记录有这个字段的值
我有以下查询来显示该表中的记录。
"select Product_Id,Product_Name,Model from ProductMaster where Status=1"
现在我想更改查询以对 Opening_Date 和 Closing_Date 进行过滤 如果它们不为空
例如:如果记录的 Opening_Date 为 05/01/2009,Closing Date 为 05/30/2009 然后我想检查今天是否是这两个日期之间的日期,如果是,则返回记录
如果两个字段值都为空,则返回记录
任何人都可以帮助我构建查询吗?提前致谢
【问题讨论】:
-
您能否说明是否应返回 opening_date 和 closing_date 设置为 null 的记录?