How can I create index on the basis of column content first 4 letter?
For example I have a table having multiple fields, one field is having name country
, all Country name is in that table.
RANK COUNTRY
--------------------------
1 Qatar
2 Luxembourg
3 Singapore
4 Brunei Darussalam
5 Kuwait
6 Norway
7 United Arab Emirates
8 Switzerland
9 United States
10 Hong Kong SAR
Now I want to do the indexing on Country
field. But I want the indexing on first 4 letter of that filed data.
This is called a "prefix" index:
INDEX(country(4))
But I don't recommend it. There are under 300 countries in this world; you may as well index the full strings.