假設有一張表 ttable
id domain1 domain2
1 abc.com test.abc.com
2 eee.com a.eee.com
update ttable set domain2=replace(domain2,domain1,'test1.com'),domain1='test1.com' where
id=1
update ttable set domain1='test1.com', domain2=replace(domain2,domain1,'test1.com') where
id=2
將會有什麼樣的結果呢?
id domain1 domain2
1 test1.com test.test1.com
2 test1.com a.eee.com
id=2的記錄為什麼replace無效了呢? 那是因為domain1在replace之前, 已經由eee.com更新成了
test1.com, 所以replace就無效了.
乙個sql的例子
select dbo.userinfo.username,dbo.userinfo.usertruename,dbo.userinfo.useremail,dbo.userinfo.usermobile,dbo.userinfo.usertelephone,dbo.userinfo.usercar,...
乙個複雜的sql
select f.course node info id as nodeid,c.course node name as nodename,c.course node type as nodelevel,c.course code,case when select course node info ...
乙個簡單的sql
declare wokno varchar 500 用來記錄職工號 declare str nvarchar 4000 用來存放查詢語句 declare count int 求出總記錄數 declare i int set i 0 select count count distinct wokno ...