我想做一个查询,但我不知道它是否可行
Select
col1,
col2,
col3,
if(contain(col3,'somethingx')) then 'hello' else 'world' as col4,
col5
from table1
换句话说,我想选择
col1
col2
col3
如果col3
包含单词'somethingx'
,那么我想选择'hello' as col4
否则我想从我的表中选择'world' as col5
。
答案 0 :(得分:4)
SELECT
col1,
col2,
col3,
CASE WHEN col3 LIKE '%somethingx%' THEN 'hello' ELSE 'world' END AS col4,
col5
FROM table1