I would like to produce a character list of all of the first letters of column in my database. The SQL below illistrats what I would like to return.
SELECT DISTINCT first_character(name) FROM mydatabase
Is there a way to do this in MySQL?
EDIT
What is the advantage of using SUBSTRING over LEFT and vice versa?
EDIT
Currently there are about 1700 records in the table and growing.
解决方案
Sorry to do this, but I figured out exactly what I needed to do just now.
SELECT DISTINCT LEFT(name, 1) FROM mydatabase
This returned a list of the first, distinct, single characters that each row in the column started with. I added changed it to the following to get it the list in alpha-numeric order:
SELECT DISTINCT LEFT(name, 1) as letter FROM mydatabase ORDER BY letter
Works like a charm.