简体   繁体   English

MySQL更新失败,带有子查询

[英]Mysql update fails, with subquery

I'm having trouble with an update query. 我在更新查询时遇到问题。 So here's the deal. 所以这是交易。

I have 2 tables, Article and Articleredefenition . 我有2个表格, ArticleArticleredefenition

In Article , I want to add the prices from Articleredefenition , however I fail to complete it. Article ,我想添加Articleredefenition的价格,但是我没有完成它。 I also want to add the products from id 300 until 620 and when there's no price filled in in the table of article 我还想将编号从300到620的产品添加到商品表中,当价格没有填写时

update Article
set Article.Price = (
select b.price
from ArticleRedefinition b, Article
where Article.ArticleId = b.ArticleId and  b.ArticleId > 300 and Article.ArticleId < 620
  and Article.Price is NULL and b.ConfigurationId = 27 )

Thanks for your help in advance! 谢谢您的帮助!

 UPDATE Article a 
    INNER JOIN ArticleRedefinition b 
    ON a.ArticleId = b.ArticleId 
    SET a.Price = b.Price 
    WHERE a.Price is NULL 
    AND (a.ArticleId BETWEEN 300 AND 620)

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM