匹配模式有:完全匹配,左匹配,中间匹配,右匹配
现在想全模糊匹配,但是匹配结果需要排序,即完全匹配在前,左匹配紧跟其后,中间匹配第三
CREATE TABLE [dbo].[test](
[name] [nvarchar](50) NOT NULL
) ON [PRIMARY]
insert into test values ('301医院')
insert into test values ('北京301医院')
insert into test values ('301医院耳鼻喉科')
insert into test values ('北京301医院眼科')
insert into test values ('301解放军总医院')
select name from test where name like '%301医院%'
order by case when name = '301医院' then 0 when name like '301医院%' then 1 when name like '301医院%' then 3 else 2 end