deleted 19 characters in body
Source Link
ypercubeᵀᴹ
  • 91.9k
  • 13
  • 188
  • 284

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like 'ci%' or name like '%ci%'
order by case when name like 'ci%' then 0 else 1 end, name;

should do what you want.

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like 'ci%' or name like '%ci%'
order by case when name like 'ci%' then 0 else 1 end, name;

should do what you want.

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like '%ci%'
order by case when name like 'ci%' then 0 else 1 end, name;

should do what you want.

edited body
Source Link
Colin 't Hart
  • 8.7k
  • 15
  • 33
  • 40

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like 'ci%' or name like '%ci%'
order by case when name like '%ci''ci%' then 0 else 1 end, name;

should do what you want.

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like 'ci%' or name like '%ci%'
order by case when name like '%ci' then 0 else 1 end, name;

should do what you want.

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like 'ci%' or name like '%ci%'
order by case when name like 'ci%' then 0 else 1 end, name;

should do what you want.

Source Link
Colin 't Hart
  • 8.7k
  • 15
  • 33
  • 40

This is quite a common problem! A case expression helps here. A query something like (untested)

select *
from table
where name like 'ci%' or name like '%ci%'
order by case when name like '%ci' then 0 else 1 end, name;

should do what you want.