简单的SQL更新不工作MS Access 2016

时间:2017-08-25 15:07:20

标签: sql ms-access

我有一个名为Inventory的表。我有一个名为Sales的第二个表。在进行销售时,我想将库存商品中商品的状态更改为"已售出。"此SQL查询不起作用,并且与销售表单上的按钮绑定:

UPDATE Inventory 
INNER JOIN Sales ON Inventory.[Vehicle ID] = Sales.[VehicleID] 
SET Inventory.[Vehicle Status] = "SOLD" 
WHERE Inventory.[Vehicle ID] = Sales.[VehicleID]

1 个答案:

答案 0 :(得分:0)

MS ACCESS的正确格式是

UPDATE Inventory 
INNER JOIN Sales ON Inventory.[Vehicle ID] = Sales.[VehicleID] 
SET Inventory.[Vehicle Status] = "SOLD";

正确的SQL格式是:

UPDATE Inventory 
SET [Vehicle Status] = "SOLD" 
FROM Inventory
INNER JOIN Sales ON Inventory.[Vehicle ID] = Sales.[VehicleID] 

如果这些sql语句不起作用,则vehicle Id可能与表中的EditText edit = (EditText) view.findViewById("myEditText"); String city = edit.getText().toString(); 不相同或缺失