I am doing a “ALPHABETICAL ORDER SEARCH” module for a project.
that is it will look like
A B C D E F . . . . . . . . . .. . . . . . . .. . . . Z
When i click on “A” the results should be sort by “A“. Which is same for all the alphabets.
Now my prob is as follows:
-
For example there is a film named “The Mummy“.
-
What i do is when click on the “ALPHABET T” this corresponding film will be sort.
-
But my client requirement is that “The Mummy” movie must sort when the user clicks on “M” and not “T”
-
Because “a, an, the” are “ARTICLES” and it does not have any meanings.
I hope now that everybody can understood what my problem is….
Any help will be appreciable and thankful.
thanks in advance
Assuming that you do not wish to modify the content of the table (and hence get slightly less efficient queries), the following should do the trick.
(If you do have the leisure of modifying the table, see the suggestions at the end of this answer)
Notes:
– x designate the desired letter (example: LIKE ‘A%’ etc.)
– The “AND TITLE NOT LIKE” extra condition is only needed when “X” is the letter “T” (it is otherwise functionally redundant, but doesn’t change the result)
– I’m unsure of the support of the the
[^xyz](i.e. NOT characters x, y or z), so the[^T]could be replaced by its positive equivalent say[A-RS-Z0-9].There are a few other stop words to consider (“A”, “AN”, “OF”…) but for book or film titles, it is a common practice to only consider “THE”. If you must deal with the other articles, the logic can be extended as in:
There are better solutions, if you can modify the table’s contents. Some of these imply pre-computing one or several extra columns (and maintaining it/these, when new records are added etc.).