有时发现在写T-SQL 中可以用
case ...
when
then
end
这一组语句后,
可以比较大程度上去除用union后的语句膨胀.
WHERE
case
when m.object_type_id in(2, 11) then ( m.object_id)
else ( m.station_id) end
= 225683000
注意.
如果写成
case
when m.object_type_id in(2, 11) then ( m.object_id)
else ( m.station_id) end
= 225683000
这样还是会
case
when m.object_type_id in(2, 11) then ( m.object_id = 225683000)
else ( m.station_id = 225683000) end
还是不会通过的