0
此SQL的最佳方式是什麼?什麼是此更新的最佳解決方案
A)
update tableName set
FieldA = (if FieldA = 1301 then null else FieldA endif),
FieldB = (if FieldB = 1301 then null else FieldB endif)
where Id = 707;
或
B)
update tableName set FieldA = null where Id= 707 and FieldA = 1301;
update tableName set FieldB = null where Id= 707 and FieldB = 1301;
在模型 「A」 我只有一個SQL的作品,並解決了這個問題,並且模型 「B」 我有兩個SQL,與「A」模型做同樣的事情,但更具可讀性。
什麼是最適合使用的模型?
我想知道即使當FieldA <> 1301時,第一個選項A)也不能觸發更新觸發器。甚至更新IO。我的意思是,引擎是否知道'更新設置FieldA = FieldA`會成爲NOP? – pascal 2011-01-24 13:01:17