查询:
SELECT SUM(amount) as order
FROM VendorTransaction
WHERE order_id = 7496
AND payment_mode = 'order'
ORDER BY id DESC
错误:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中出错;查看与您的MySQL服务器版本对应的手册,以便使用接近'顺序的正确语法 FROM VendorTransaction
答案 0 :(得分:2)
订单是另一个保留字更改
SELECT SUM(amount) as my_order
FROM VendorTransaction
WHERE order_id = 7496
AND payment_mode = 'order'
ORDER BY id DESC
或使用背景
SELECT SUM(amount) as `order`
FROM VendorTransaction
WHERE order_id = 7496
AND payment_mode = 'order'
ORDER BY id DESC
答案 1 :(得分:0)
使用它: 选择SUM(金额)作为' order' FROM VendorTransaction WHERE order_id = 7496 AND payment_mode =' order' ORDER BY id DESC