我在MySQL数据库中使用这一行:
SELECT * FROM `dump` USE INDEX `time_desc` WHERE (`nodeId`=10047 AND `time`<=1377040709 AND `valid`=1) ORDER BY `time` DESC LIMIT 1;
我无法弄清楚原因,但数据库返回以下错误:
[错误:ER_PARSE_ERROR:您的SQL语法中有错误;校验 与您的MySQL服务器版本对应的手册 在'time_desc WHERE
nodeId
= 10048 AND附近使用的语法time
&lt; = 1377040709 ANDvalid
= 1在第1行的'ti'订购]
有关我如何解决这个问题的想法吗?
答案 0 :(得分:2)
您需要围绕索引名称
的括号SELECT *
FROM `dump` USE INDEX (`time_desc`)
WHERE (`nodeId`=10047 AND `time`<=1377040709 AND `valid`=1)
ORDER BY `time` DESC
LIMIT 1;
答案 1 :(得分:0)
试试这样: -
SELECT * FROM `dump` USE INDEX (`time_desc`) --Use paranthesis here
WHERE (`nodeId`=10047 AND `time`<=1377040709 AND `valid`=1)
ORDER BY `time` DESC
LIMIT 1;
选中reference。