In this days, I am making dictionary site with PHP & Mysql.
I write SQL like this
select * from dblist
where `Word`='A'
Union
select * from dblist
where `Word`like 'A%'
Union
select * from dblist
where `Word`='%A%'
Union
select * from dblist
where `Word`='%A'
I don't use
`Word`='A' OR `Word`like 'A%' OR `Word`like '%A%' OR `Word`like '%A'
because the result show it order by id.
I want to show
First Match with A
Second Start With A
Third A in the middle
Fourth End with A
When I use Or the result ordery is not like that.So, I am using Union. But I think,sql is long and it may be slow for searching. How should I change it ? Any advice for me ?