如何上传内部联接的列? [英] how can I upload some column with inner join?
本文介绍了如何上传内部联接的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请看这篇文章
如何比较两个表并删除mysql程序中的一些数据? [ ^ ]
这样的另一个问题
有两个表相同;
支付表有product_id和添加了多少产品:number
产品表同上面product_id和库存
为ex X产品库存= 10我已付或添加2因此产品表库存必须更新新值8.
我试过上面但我不能
update [products] 设置股票=股票编号
WHERE products_id IN (
SELECT cb.products_id,数字 FROM [pay] cb
INNER JOIN [products] p ON cb.products_id = p.products_id
WHERE cb.situation = 1)
情况= 1
表示已付款
解决方案
试用此代码:
#Pay有3列(ProductName,Added,Situation)
#Product有2列(ProductName,Stock)
更新 x
SET x.Stock = x.Stock - y.Added
FROM #Product x
INNER JOIN #Pay y ON x.ProductName = y.ProductName
WHERE y.Situation = 1 跨度>
please look this article
how can I compare two table and delete some data in mysql procedures?[^]
another question like this
there are two table same as;
pay table has product_id and how many product added so: number
product table same above product_id and stock
for ex X product stock=10 I paid or added 2 so product table stock must be update new value 8.
I tried like above but I cant
update [products] set Stock=Stock-number
WHERE products_id IN (
SELECT cb.products_id,number FROM [pay] cb
INNER JOIN [products] p ON cb.products_id = p.products_id
WHERE cb.situation=1)
situation=1
means paid
解决方案
Try this code:
#Pay has 3 Columns (ProductName, Added, Situation)
#Product has 2 columns (ProductName, Stock)
UPDATE x SET x.Stock = x.Stock - y.Added FROM #Product x INNER JOIN #Pay y ON x.ProductName = y.ProductName WHERE y.Situation = 1
这篇关于如何上传内部联接的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文