php - Ordering MySQL string results without a defined Collation? -
say have next results:
mackay mackay airport melbourne melbourne airport sydney sydney ac sydney airport
how can create ordered airport @ top of them? alphabetically, eg:
mackay airport mackay melbourne airport melbourne sydney airport sydney sydney ac
a bit confused on how create airports more prominent.
not sure if next query covers cases, seems work sample data:
select name, substring_index(name,'airport',1) l, locate('airport',name) r ( select 'sydney airport' name union select 'sydney' union select 'sydney ac' union select ' mackay airport' union select 'mackay' union select 'melbourne' union select 'melbourne airport' )a order l asc, r desc
with table
select name table1 order substring_index(name,'airport',1) asc, locate('airport',name) desc
php mysql order collation
No comments:
Post a Comment