SQL 语句 之 增删改查 (一)

本语句基于Microsoft SQL Server

--Insert From Selecter
Insert into DTOClass (F1,F2,F3) select T2.F1,T2.F2,T2.F3 from DTOClass2 T2 where t2.F1='xx'

--删、改、查语法一致
Delete from DTOClass from DTOClass T1,DTOClass2 T2 where T1.F1=T2.F1 and T1.F2=T2.F2 and T2.F3 = 'XX'
Delete from DTOClass from DTOClass T1 inner join DTOClass2 T2 on T1.F1=T2.F1 and T1.F2=T2.F2 where T2.F3 = 'XX'

--Set 左侧没有Alias
Update DTOClass Set F3='F3_xx' from DTOClass T1,DTOClass2 T2 where T1.F1=T2.F1 and T1.F2=T2.F2 and T2.F3 = 'XX'
Update DTOClass Set F3=T2.F3 from DTOClass T1 inner join DTOClass2 T2 on T1.F1=T2.F1 and T1.F2=T2.F2 and T2.F3 = 'XX'

Select T1.F1,T1.F2,T2.F1,T2.F2 from DTOClass T1,DTOClass2 T2 where T1.F1=T2.F1 and T1.F2=T2.F2 and T2.F3 = 'XX'
Select T1.F1,T1.F2,T2.F1,T2.F2 from DTOClass T1 inner join DTOClass2 T2 on T1.F1=T2.F1 and T1.F2=T2.F2 and T2.F3 = 'XX'



posted on 2011-12-10 16:01  Ivan.Lee  阅读(174)  评论(0编辑  收藏  举报

导航