修改 请忽略 - 我是在深夜做的,因为它没有注意到语法错误
我正在尝试删除最后一条记录,但是我收到语法错误。我的查询中的错误在哪里?
DELETE t1 FROM mydb.PauseResume AS t1
JOIN (SELECT `timestamp` FROM mydb.PauseResume ORDER_BY `timestamp` DESC LIMIT 1) AS t2
WHERE `t1`.`timestamp` = `t2`.`timestamp`
答案 0 :(得分:3)
ORDER_BY
应为ORDER BY
。没有下划线。
答案 1 :(得分:1)
我想你应该点击的是:
DELETE t1.* FROM mydb.PauseResume AS t1
JOIN (SELECT `timestamp` FROM mydb.PauseResume ORDER BY `timestamp` DESC LIMIT 1) AS t2
WHERE `t1`.`timestamp` = `t2`.`timestamp`
有关MySQL语法的详细信息,请查看:
答案 2 :(得分:0)
在JOIN中你也需要一个ON语句。您尝试使用WHERE子句执行此操作。
应该是
DELETE t1 FROM mydb.PauseResume AS t1
(SELECT `timestamp` FROM mydb.PauseResume ORDER BY `timestamp` DESC LIMIT 1) AS t2
ON (`t1`.`timestamp`=`t2`.`timestamp`);