如何在`SQL`中使用`LIKE`运算符作为列?

时间:2013-04-25 14:40:04

标签: sql sql-server-2008

我想将LIKE运算符用作以下列:

SELECT name, (name LIKE '%flow%') AS bool1
FROM table1
WHERE ...

得到结果:

name                 bool1
--------------     ----------
over flow              1
stack over flow        1
stack over             0

1 个答案:

答案 0 :(得分:4)

select name, case when name like '%flow%' then 1 else 0 end as bool1 
from table1 
where...