sqlserver更新語句

時間 2021-09-13 06:14:36

1樓:匿名使用者

update table_1 set code = 333

where exists

( select top 2 id,name from table_2

where table_1.id=id and table_1.name=name order by id)

不知道你的top的用意,如果確實只提取子查詢的前兩條估計要麻煩點寫了

update table_1 set code = 333

where id in ( select top 2 id from table_2 order by id)

and name in ( select top 2 name from table_2 order by id)

2樓:

update table_1 set code = 333

where id in ( select top 2 id,name from table_2 ) and name in ( select top 2 id,name from table_2 )

sql 同時更新一張表裡的一個欄位所有資料

3樓:流浪雲風

如果更新成同一個值,按如下語句就行了:

update [表名] set [欄位名] = [值];

如果是根據一個表更新此表,套用如下方式:

update [表名] set [欄位名] = (select [欄位名] from [其他表] where [兩表間的關聯條件]);

希望對你有幫助。

4樓:mingtian是吧

create proc updat_test @name char(8), @nu int    --建立儲存過程

as update tabname    --修改表明set name=@name where number=@nugoexec update_test ,@name='張三' ,@nu='112233'  --只需修改“張三”和“112233”

5樓:不知光年

update 表 set 欄位1=值

或update a set a.欄位1=b.欄位1 from 表1 a,表2 b where 表1與表2的關聯條件

關於delphi更新語句,delphi操作access資料庫update語句錯誤

sql update yonghu set jifen trim edit.text jifen where id edit1.text 補充,由於jifen是number型,所以只要1個單引 號,id如果是varchar,需要3個單引號adoquery1.sql.clear adoquery1.s...

求常用的sql server查詢語句,謝謝

select from 表名 不帶條件查詢 select from 表名 where id 1 帶條件查詢 select count from 表名 查詢記錄條數 給你個連結,50句強大sql 學會你的基本功就過關了,http blog.csdn.net liangck archive 2008 1...

sqlserver用sql語句查詢結果插入到新的資料庫中

可以這樣子寫 先寫乙個自定義函式 create function cre funcation a int returns varchar 2000 as begin declare str varchar 2000 set str select str str rtrim a.b from test...