I have a similar query as asked on this question
MySQL - How to ORDER BY RELEVANCE? INNODB Table
Difference is, here I want to search from 5 fields as
add1, add2, add3, post_town, post_code
And only records in post_code field will be NOT EMPTY, other fields records may be empty at some places. If I search for keyword kingston, it returns
Acre Road, Kingston upon Thames, KT2 6EA
Kingston Road, Epsom, KT19 0DG
Kingston Road, Epsom, KT20 0DH
and these results are combination of all fields add1, add2, add3, post_town, post_code
I need this result in following order
Kingston Road, Epsom, KT19 0DG
Kingston Road, Epsom, KT20 0DH
Acre Road, Kingston upon Thames, KT2 6EA
My Current SQL query is like this
SELECT add1, add2, add3, post_town, post_code FROM address_mst
WHERE add1 LIKE '%".$keyword."%'
OR add2 LIKE '%".$keyword."%'
OR add3 LIKE '%".$keyword."%'
OR post_town LIKE '%".$keyword."%'
OR post_code LIKE '%".$keyword."%'
So I need records with search Keyword coming in the beginning would come first. How can I do that ?