数据库:SqlServer
- --create table--
- create table table1 (
- column1 nvarchar(200),
- column2 nvarchar(200)
- );
- --insert data--
- insert into table1(column1,column2) values ('_abc_','aasf');
- insert into table1(column1,column2) values ('_acbc_','aasf');
- insert into table1(column1,column2) values ('23','ggg');
- insert into table1(column1,column2) values ('_def_','aasf');
- insert into table1(column1,column2) values ('asdf','3123');
- --search as type--
- Select
- type = case when column1 like '%_abc_%' then 'a'
- when column2 like '%GGG%' then 'b'
- when column1 like '%_def_%' then 'c'
- else 'others' end,
- column1,
- column2
- from table1
- where 1=1