« MySQL errno 150 | Main | MySQL Pop Quizzes: Now in Spanish and Russian! »
REVERSE() :: MySQL Function of the Day
By Carsten | April 14, 2008
Function name: REVERSE()
Aliases: -
Function type: String function
Purpose: Return a string with characters in reverse order
Description: REVERSE(’bitbybit.dk’) does what you expect: returns ‘kd.tibybtib’.
The most prominent place you can use REVERSE is when storing host names for email addresses, web services, etc. where you expect that you’ll want to look up addresses based on the domain name only. Obviously, you could do that as well by using …LIKE ‘%bitbybit.dk’. In that case, however, MySQL would not be able to use any index on the column as that is always based on the left-most part of the column value. By storing (and searching on) the reversed string, you can utilize an index.
MySQL manual entry on REVERSE()
[fadps]
Topics: MySQL Function of the day |
April 21st, 2008 at 12:15 pm
[...] Monday, April 14th 2008:REVERSE() [...]