摘要: update的格式是:update table1set table1.name=’abc’ from table1inner join table2on table1.id = table2.idwhere table2.number = '123'delete 的格式是:delete from table1 from table1 inner join table2 on table1.id = table2.id注意蓝色部分,这样就可以省掉复杂的中间表了^_^ 阅读全文
posted @ 2011-10-14 09:06 litsword 阅读(2383) 评论(0) 推荐(0) 编辑
摘要: 今天遇到一个错误,自己一直没有意思到这样写是错误的。在游标循环过程中使用变量要注意declare @a;select @a =column1 from table1 where column2 = '123'if @a is nullbeginend原以为如果找不到'123'的记录,变量@a 会被赋成null,可事实上,@a 会保留上一次loop取到的有效值(即非null的历史值)应该改为set @a = select column1 from table1 where column2 = '123'这样才能在找不到记录时正确将@a设置为null 阅读全文
posted @ 2011-10-14 09:02 litsword 阅读(825) 评论(0) 推荐(0) 编辑