Page 1 of 1

[Solved] Searching for sub-strings

Posted: Sat Sep 03, 2005 11:34 am
by davidtee1
I want to find all the records in a database that begin with "a", "b" etc and count the results.

Something like:

SELECT * FROM table WHERE word STARTS_WITH "a" (!)

I am sure this is trivial but I can't find the right WHERE clause to use.

Any help gratefully received.

David

Posted: Sat Sep 03, 2005 11:35 am
by josh

Code: Select all

SELECT count(*) FROM `table` WHERE `field` LIKE 'a%'
% is the wildcard, this returns the count where fields start with a

Posted: Sat Sep 03, 2005 11:36 am
by davidtee1
Thanks - I knew it would easy, but couldn't find the wildcard.