我想获取某个日期间隔之间的所有行,结果集最多为50条记录。什么可以查询?我不断收到错误:
$sql = "SELECT DISTINCT userId FROM ".$TableName.
" where time BETWEEN (NOW() - INTERVAL "
.$USER_COUNT_DURATION.
" MINUTE AND NOW()) LIMIT 0, ".$limit." ;";
答案 0 :(得分:1)
看起来像括号问题。 “MINUTE AND NOW())”应该是“MINUTE”和NOW()“
$sql = "SELECT DISTINCT userId FROM ".$TableName." where time BETWEEN (NOW() - INTERVAL ".$USER_COUNT_DURATION." MINUTE) AND NOW() LIMIT 0, ".$limit." ;";