茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1729864 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00213.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

DB研討會 : [轉貼]如何更新資料表欄位透過其他資料表(UPDATE FROM TABLE)

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15773
[轉貼]SQL 從另一個表格更新資料

SQL 從另一個表格更新資料

Update data in one table with data from another table.
假設 History table 只有 Product_id, 現在新增 Product_Name column, 但資料再另一個 table 有, 要怎樣更新.


以往使用 MS SQL 做這件事非常簡單, 語法也很易懂.

update history 
set product_name=product.product_name
from history, product
where history.product_id=product.product_id


如果是 Oracle : 

update history h
set product_name=(select product_name from product p where p.product_id=h.product_id)
WHERE EXISTS( SELECT product_name FROM product p where p.product_id=h.product_id)


原文出處:
SQL 從另一個表格更新資料 @ 老爹寫程式 :: 痞客邦 PIXNET ::
前一個主題 | 下一個主題 | | | |

討論串




Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|