我有一个SQL查询语句,它检索出一列字符串值。我想在旁边创建一个列,如果该值包含子字符串“MB”,则其取值为1,否则为0。
CASE WHEN THEN
select case when INSTR('mycol', 'MB') > 0 then 1
else 0
end as myBoolCol
pos
和 len
的值? - René Hoffmann'MB'
字符串。 - Rahul Tripathiselect column,
case when column like '%mb%' then 1
else 0 end
from table
这适用于MSSQL和MYSQL