0

基本上我有这个查询

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 无效语法

有任何想法吗???

4

1 回答 1

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
)
于 2013-07-16T16:11:41.093 回答