Close

Not a member yet? Register now and get started.

lock and key

Sign in to your account.

Account Login

Forgot your password?

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

20 一月 DB資料庫 | Comments

查證後…用字串的日期比對,會比用 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’) ";
 

Leave a Reply

*