【发布时间】:2017-04-19 07:25:18
【问题描述】:
我正在尝试按价格过滤产品,但遇到了特价问题。
如果特价适用于产品,则以下查询显示随机结果。
"SELECT * FROM tablename WHERE ((price >= ".(int)$min_price." AND price <= ".(int)$max_price." AND ('".date('Y-m-d')."' NOT BETWEEN special_price_startdate AND special_price_enddate OR special_price_startdate = NULL OR special_price_enddate= NULL)) OR (('".date('Y-m-d')."' BETWEEN special_price_startdate AND special_price_enddate AND special_price_startdate IS NOT NULL AND special_price_enddate IS NOT NULL) AND special_price >= ".(int)$min_price." AND special_price <= ".(int)$max_price.")) AND isactive = 1 AND isdeleted = 0 ORDER BY created DESC, productid DESC LIMIT ".(($page-1)*$perpage).",".$perpage;
【问题讨论】:
-
如果您能告诉我们您期望的结果和实际得到的结果,我们会更容易提供帮助!