I have a music site. Where song will be categorized like A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z and all letters have a active link. I need to Fetch Data In Alphabetic. That means when i press "A" then all data with first name "A" or "a" will be shown. How can i do it? Please help me.
it can be done using query similar to following.. SELECT * FROM table_name WHERE song_name LIKE 'A%' If you can post table structure and examples, we can help you get exact query.
I would do: SELECT * FROM table_name WHERE UCASE(song_name) = 'A'; LIKE statements tend to be hard on resources.
@jestep, unless there is a separate field storing first letter of song name, the query you gave won't yield desired result. Like are little hard but with proper index they can give fast results. I would suggest to keep a separate column having first letter of song name in it and use the query given by jestep on that column to retrieve the data
mastermunj's first query will return the desired results. This query requires full table scan even if you create an index on this column due to row operation (ths use of UCASE). No need to create a separate column to keep the first letter of song name. Instead create an INDEX on first 1, 2 or more characters (according to your requirement) of the song name and use the query provided by mastermunj. This kind of LIKE query uses index. Like queries containing condition similar to '%A' are resouce intensive and requires full table scan.