我有MySQL Server版本5.1.53.我在找一个小时自己回答这个问题.包括阅读文档本身http://dev.mysql.com/doc/refman/5.1/en/select.html
当前,我运行此查询.
SELECT dv2.timestamp
FROM data_val AS dv2
WHERE dv2.timestamp > '2011-06-10 22:26:25' ORDER BY dv3.timestamp DESC
LIMIT 1
然后,我试图通过确定MAX_QUERIES减1的计算来消除ORDER BY语法.
SELECT (COUNT(*)-1) total
FROM data_val AS dv2a
WHERE dv2a.timestamp > '2011-06-10 22:26:13'
最终查询变为
SELECT dv2.timestamp
FROM data_val AS dv2
WHERE dv2.timestamp > '2011-06-10 22:26:13'
LIMIT (
SELECT (COUNT(*)-1) total
FROM data_val AS dv2a
WHERE dv2a.timestamp > '2011-06-10 22:26:13'
), 1
错误是:
#1064-您的SQL语法有误;检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第4行的'(SELECT(COUNT(*)-1)total FROM data_val AS dv2a’附近使用
我还尝试将子查询放在OFFSET语法之后.但仍然错误.
您是否知道为什么我的子查询不起作用?
I need technical details with short,
simple, and clean explanation.