|
Posted by Anith Sen on 12/20/07 19:19
Not sure how involved this requirement is. If you want to get the list of
alphabets from the existing titles, you can have simple query like:
SELECT DISTINCT LEFT( titles, 1 ) AS "alpha"
FROM tbl
ORDER BY "alpha" ;
In many cases, for fast searching and indexing, people implement other
alternatives. One variation is to have another table that is referenced back
to the titles table. Another one with smaller list could be a computed
column that is indexed with the expression: LEFT( titles, 1 ) etc.
If you want all the alphabets displayed regardless of existing titles, you
can easily generate them on the client side itself. Most web development
tools have build in functions that does this in a quick loop. If you want to
do this with t-SQL, you can use the CHAR() function on a simple query like:
SELECT CHAR( n )
FROM Nbrs
WHERE n BETWEEN 65 AND 90 ;
Regarding how the table Nbrs is created, see:
www.projectdmx.com/tsql/tblnumbers.aspx
--
Anith
Navigation:
[Reply to this message]
|