通过'订购'在mysql的where子句中

时间:2018-01-27 10:13:02

标签: mysql mysqli

查询

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

2 个答案:

答案 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