select * from A
WHERE pro like '%8890%'
OR pro like '%14672%'
OR pro like '%14400%'
查询出来,按我输入条件(8890,14672,14400)
顺序显示出来?**** 8890 ****
**** 14672 ****
**** 14400 ****
WHERE pro like '%8890%'
OR pro like '%14672%'
OR pro like '%14400%'
查询出来,按我输入条件(8890,14672,14400)
顺序显示出来?**** 8890 ****
**** 14672 ****
**** 14400 ****
WHERE pro like '%8890%'
OR pro like '%14672%'
OR pro like '%14400%'
order by
case when pro like '%8890%' then 1 when pro like '%14672%' then 2 when pro like '%14400%' then 3 end
from A
WHERE pro like '%8890%' OR pro like '%14672%' OR pro like '%14400%'
order by
case
when pro like '%8890%' then 1
when pro like '%14672%' then 2
when pro like '%14400%' then 3
end
*
from
A
WHERE
pro like '%8890%' OR pro like '%14672%' OR pro like '%14400%'
order by
case
when pro like '%8890%' then 1
when pro like '%14672%' then 2
when pro like '%14400%' then 3
end
from A
WHERE
pro like '%8890%'
OR
pro like '%14672%'
OR
pro like '%14400%'
order by
case
when pro like '%8890%' then 1
when pro like '%14672%' then 2
when pro like '%14400%' then 3
end
楼主,这样虽然可以达到目的,但是效率是非常差的.
insert #tb1
select '000001',8890,'zhang' union allselect '000003',14400,'wang' union allselect '000002',14672,'li'select * from #tb1
order by (case when pro like '%8890%' then 1 when pro like '%14672%' then 2 when pro like '%14400%' then 3 end)
WHERE pro like '%8890%' OR pro like '%14672%' OR pro like '%14400%'
order by (case when pro like '%8890%' then 1 when pro like '%14672%' then 2 when pro like '%14400%' then 3 end)