SqlServer deletions in the case of the associated change search

UPDATE

update table set 1 = value1 column names, column names 2 = value2 ...

update a   set a.name=b.name from STUDENTSas a inner join Class as b on a.StuId = b.ClassId

 

update Class as C set(ClassName,ClassDesc)= (select (StuName,StuDesc) from STUDENTS as S  where S.StuId=C.ClassId)

 

INSERT:

1、insert into 表名 values(value1,value2,value3...)

2, INSERT table (column 1, column 2, column 3) values ​​(value1, value2, value3 ...)

insert and insert into the difference: insert into table values ​​(value1, value2, value3 ...) must be assigned for all the columns in the table, even though the values ​​in the column can be empty

 

insert table (column 1, column 2, column 3) values ​​(value1, value2, value3 ...) in the first few columns bracket, the second bracket will fill several data

insert into select ……

insert into table2 (column 1, row 2, row. 3) SELECT VALUE1, value2 from table1 or: INSERT INTO table2 SELECT * from table1 [Note]: table1 and table2 table structure to be consistent

insert bulk insert data into a plurality of associated tables:

 

DELETE

delete from table ...... can be used in conjunction with where

delete 关联:delete a from table1 a inner join table2 b on a.ID=b.ID

 

Guess you like

Origin www.cnblogs.com/decoct-tea/p/12466166.html