基本上我有这个查询
SELECT *
FROM `transactions` a
WHERE Round(( tender1 - `change` ), 2) != (SELECT Round(Sum(total), 2)
FROM `transactions` b
WHERE b.trans_no = a.trans_no)
AND tender1 != 0
LIMIT 1
这很好并且返回单行但是如果我将语句更改为删除
DELETE FROM `transactions` a
WHERE Round(( tender1 - `change` ), 2) != (SELECT Round(Sum(total), 2)
FROM `transactions` b
WHERE b.trans_no = a.trans_no)
AND tender1 != 0
LIMIT 1
这会返回错误1064无效语法
任何想法???
答案 0 :(得分:0)
我不确定你为什么会有LIMIT
,但我认为如果你想删除任意一行,这会有效:
DELETE FROM `transactions` WHERE id IN (
SELECT id FROM `transactions` a
WHERE ROUND((TENDER1 - `CHANGE`),2) != (SELECT ROUND(SUM(TOTAL),2)
FROM `transactions` b
WHERE b.trans_no = a.TRANS_NO)
AND TENDER1 != 0
LIMIT 1
)