一条简单的SQL语句问题
有两张表,表一是Sell,表二是Product。最终得要修改的是表一Sell里的字段1(DocNum)=表二Product里的字段1(DocNum) 并且 表一Sell里的字段2(LineNum)=表二Product里的字段2(LineNum)如果满足以上两个条件就修改表一Sell里的字段Statics=‘A’
我是这样写的,报,号旁边有错:
update Sell,Product set Sell.Statics = '已排程 ' where Sell.DocNum = Product.DocNum and Sell.LineNum = Product.LineNum
请高手指点,给出正确SQL语句。
------解决方案--------------------update Sell s,Product p set Sell.Statics = '已排程 ' where s.DocNum = p.DocNum and s.LineNum = p.LineNum
------解决方案--------------------update Sell set Sell.Statics = '已排程 ' where exists (select 1 from Product where Sell.DocNum = Product.DocNum and Sell.LineNum = Product.LineNum)
------解决方案--------------------try:
update Sell set Statics = '已排程 ' from sell inner join Product on Sell.DocNum = Product.DocNum and Sell.LineNum = Product.LineNum
------解决方案--------------------楼上正解
update Sell set Statics = 'A ' from sell inner join Product on Sell.DocNum = Product.DocNum and Sell.LineNum = Product.LineNum