SQL server 2019怎麼從有相同ID號的那條資訊中取用有用的資訊放到和它有相同ID的行中呢

2022-03-10 19:16:54 字數 982 閱讀 2772

1樓:匿名使用者

如果你的資料只是像你寫的這樣

update t1 set t1.b=t2.b,t1.

c=t2.cfrom test t1 inner join (select a,max(isnull(b,0)),max(isnull(c,0))

from test

group by a) t2 on t1.a=t2.awhere isnull(b,0)=0 and isnull(c,0)=0

注:id   =a      身高=b         年齡=c這樣就可以了;

樓下 ab594418159 的方式也可行,直接子查詢查詢出b,c為空的就可以了,,

遊標的方式,,還是算了

2樓:石頭

查詢出所有身高年齡不為空的資料 select * from tab where 身高<>'' and 身高 is not null

更新空的資料 update tab set tab.身高=t.身高,tab.年齡=t.年齡 from tab,(上面的語句) t where tab.id=t.id

3樓:來學習的

如果你相同id的資料是唯一的話我有個 本方法確實可行;

update tablename set height=(select height from tablename where tablename.id=?

and tablename.height is not null),age=(select age from tablename where tablename.id=?

and tablename.age is not null) where id=?

4樓:左鵬翼

用update試試吧

update t set from(select * from tablename) as t where 身高='' or 年齡=''

sql server2019的資料庫怎麼恢復到mysql裡

1 sql server 2000資料匯入到sql server 2005中 好的是微軟的產品一般都對之前的產品比較相容,在sql server 2000中,只需要把其資料進行備份,在對應的資料庫中點選右鍵,然後選擇 所有任務 下的 備份資料庫 就彈出一個對話方塊,然後點選 新增 按鈕,輸入對應的資...

sql server 2019安裝時服務賬戶如何配置

解決bai方法 先把sql server解除安裝,再把安裝時產生du的 microsoft sql server 資料夾刪掉zhi,在執行登錄檔 dao,把hkey current user software microsoft microsoft sql server,和hkey local ma...

安裝sql server 2019時沒有配置sqlserve

1.用windows身份驗證登陸 這個應該是不會存在問題的,在新安裝好例項 sql server 的情況下,windows身份驗證是不可能被禁用的 安裝過程中沒有可以設定禁用windows身份驗證的地方 manage studio 選單 檔案 連線物件資源管理器 身份驗證中選擇 windows au...