find all the name using mysql query which start with the letter 'a'

Viewed 135074

I want to find the data from table artists where name is start with letter a, b, c.

i.e. 
My o/p should contain
Adam
Alan
Bob
Ben
Chris
Cameron

But not GlAin, doC, dolBie
7 Answers

You can use like 'A%' expression, but if you want this query to run fast for large tables I'd recommend you to put number of first button into separate field with tiny int type.

Try this:

select * from artists where name like "A%" or name like "B%" or name like "C%"

One can also use RLIKE as below

SELECT * FROM artists WHERE name RLIKE '^[abc]';
Related