什么能更快地发挥作用:
OR
答案 0 :(得分:0)
如何使用case
语句两者:
select (case when <where1> then 1 else 0 end) as Where1,
(case when <where2> then 1 else 0 end) as Where2,
. . .
然后你可以带回一小组行,并确定它们在应用程序中的位置。
您的问题很难回答,因为它取决于处理查询,返回结果以及浏览应用程序中的结果集所花费的时间。一般来说,我认为返回成千上万行是一件坏事(性能方面),而只返回少量行。但是,在某些环境中,它可能是更好的方法。
如果所有where
子句都返回不相交的行集,那么您可以将它们放在一个派生列中:
select (case when <where1> then 'where1'
when <where2> then 'where2'
. . .
end) as which