SQL语句:
update table_1 set x = (select x from table_2 where table_1.y =  table_2.y);
如果括号中临时建立的表中元素的个数小于table_1中元素个数或者只想更新table_1中部分x的值,可以在后面加where子句.

Example:
更新产品库存:
update product set stock=(select stock from left where left.product_id=product.product_id) where product_id in (select product_id from left)

 

相关文章:

  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
相关资源
相似解决方案