TSQL - like question
What is a better way to write the following transact SQL?
select * from table1 whe开发者_如何学JAVAre columnA like '%ABC%' and columnB = 1
select * from table1 where columnA like '%DEF%' and columnB = 1
select * from table1 where columnA like '%GHI%' and columnB = 1
is it possible to consolidate the above 3 sql statements into a single select statement
select * from table1
where (columnA like '%ABC%'
or columnA like '%DEF%'
or columnA like '%GHI%')
and columnB = 1
select *
from table1
where columnB = 1 and
(columnA like '%ABC%' or
columnA like '%DEF%' or
columnA like '%GHI%')
You can try this
select * from table1
where (columnA like '%ABC%'
or columnA like '%DEF%'
or columnA like '%GHI%')
and columnB = 1
精彩评论