?
Solved

getting the first alphabet of a field

Posted on 2000-03-07
3
Medium Priority
?
221 Views
Last Modified: 2006-11-17
I want to basically develop an alphabetical search engine so that  if a user Clicks on 'A'  all the titles whose name starts with A are displayed, and likewise for all the other alphabets. But the problem is that some titles begins with Numbers (for eg. 123ofcricket) and some even with special characters such as 'alpha', 'beta' and the list is very long. One more requirement is that suppose no title begins with 'X' than X should not be displayed in the search list.

I am thinking of runing a select statement with a distinct clause to retreive all the first letters of title from the table, but I could not create the SQL query.

I am using a MySql database with Php as the scripting language.

Can anybody please help or suggest any other suitable method.
Kindly help with example.

Thanks
Qader
0
Comment
Question by:qader99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
maxkir earned 75 total points
ID: 2590880
SELECT DISTINCT LEFT(col, 1) FROM $table;
0
 

Author Comment

by:qader99
ID: 2591093
Thankyou Maxkir

I got the desired results from the select statement you provided
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2592105
Read Mysql docs more throughly ;-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question