Not sure where to put the GROUP BY clause in this SQL. Can anyone help?
select * from uk_postcode_towns where town like '%madi%'
order by case
when town like 'madi%' then 0
when town like '% %madi% %' then 1
when town like '%madi' then 2
else 3 end, town
I have a problem in that if I enter “Madison” into the query, it should retrurn all places with the name “Madison” in them. Currently this query is only returning the first exact match of Madison. Do you know what I need to change in the query to return all Madison matches? I thought a group by was the answer, but maybe not
select * from uk_postcode_towns where town like ‘%madison%’
order by case
when town like ‘madi%’ then 0
when town like ‘% %madi% %’ then 1
when town like ‘%madi’ then 2
else 3 end, town