字串的日期比對 vs BETWEEN AND 語法效率

20一月

字串的日期比對 vs BETWEEN AND 語法效率

查證後…用字串的日期比對,會比用 BETWEEN…AND 語法,來得有效率

例如…

$sqlCondition .= "AND a.publishDate >= ‘" . sqlStr($beginDate) . " 00:00:00’ ";
$sqlCondition .= "AND a.publishDate < ‘" . sqlStr($endDate) . " 00:00:00’ ";

V.S.

$sqlCondition .= "AND (a.publishDate BETWEEN ‘" . sqlStr($beginDate) . " 00:00:00’ AND ‘" . sqlStr($endDate) . " 00:00:00’) ";
 

Posted by chihwen  Posted on 20 一月 
  • SQL語法
  • Post Comments 0