我有一个MySQL数据库,里面有一个名为ProductMaster的表,其中有6个字段“Product_Id,Product_Name,Model,Opening_date,Closing_Date,Status”。 Opening_Date和Closing Date可以接受空值。因此有些记录具有此字段的值Mysql查询:Where子句如果存在
我有以下查询来显示此表中的记录。
"select Product_Id,Product_Name,Model from ProductMaster where Status=1"
现在我想改变查询到对Opening_Date和Closing_Date 的过滤器,如果它们不为空
例如:如果一个记录是有Opening_Date为2008.01.29和截止日期如2009年5月30日 然后我想检查是否今天是在这两个日期之间,如果是一个日期,返回记录
如果两个字段值都为空,返回记录
可以在任何Ø ne帮我构建查询?在此先感谢
你能否澄清一下,如果记录的opening_date和closing_date设置为null应该返回? – mattkemp 2009-05-07 02:09:03