MysqlConn.Open()
command.Connection = MysqlConn
command.CommandText = CommandType.Text
command.CommandText = "UPDATE product SET `stocks` = @stocks - quantity from 'anothertable' WHERE `itemname` = @item"
With command.Parameters
End With
我不知道我该怎么做。任何帮助?如何获取和参数化数据库中的行?
答案 0 :(得分:1)
您正在寻找update-join
语法,如下所示some_column
是公共列(或)关系列(与FOREIGN KEY
相关)
UPDATE product p
JOIN anothertable a
ON p.some_column = a.some_column
SET `stocks` = @stocks - a.quantity
WHERE p.`itemname` = @item;