我正在使用SQL Server 2008 Enterprise。现在我有两种模式来实现相同的功能(查看zoo1或zoo2或zoo3列是否包含一些文本,在模式1中,我合并了zoo1,zoo2和zoo3的内容以形成一个名为zoo的新列),我认为第一个模式总是比我的实验更好的表现(我做了一些实验)。但我不确定我是否正确,模式1的表现总是更好的内部原因是什么?SQL Server like statement issue
模式1:
Select foo, goo from tablefoo where zoo like LIKE '%'[email protected]+'%'
模式2(动物园是我合并柱zoo1,zoo2和zoo3的内容,以生成一列):
Select foo, goo from tablefoo where (zoo1 like LIKE '%'[email protected]+'%') OR (zoo2 like LIKE '%'[email protected]+'%') or (zoo3 like LIKE '%'[email protected]+'%')
由于事先 乔治
非常有趣的问题。 – 2010-09-09 07:31:14
你如何构建组合列“动物园”?你是否在使用视图,如果是,它是否被索引?您是否使用计算列,如果是,它是否持续?顺便说一句,您的查询可能容易受到SQL注入攻击。 – 2010-09-09 07:40:32
本周我已经回答了类似的问题http://stackoverflow.com/questions/3649673/what-indices-should-be-created-to-optimize-sql-query-with-multiple-or-conditions/3656415 #3656415 SQL索引几乎落在查询或a或b或c它更好做工会和单独的查询 – u07ch 2010-09-09 07:45:39