Providing Computer Help and Support to business in and around Hastings, St Leonards, Battle and Bexhill, East Sussex. Also has a few snippets of random things.

Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Wednesday, May 13, 2009

Returning an alphabetical list consisting of the first letter in MySQL

In a recent project, one task involved returning the unique first letter of the data held in a MySQL field in order to provide hyperlink navigation through the web-site as opposed to a drop down menu.

This was accomplished using the MySQL statement below;

SELECT DISTINCT (left( [field], 1 ) )FROM `[table]` ORDER BY [field]