Forum Moderators: open

Message Too Old, No Replies

select where first letter is numeric

         

babushka

6:26 am on Sep 6, 2008 (gmt 0)

10+ Year Member



Hi, I am trying to select all records where the first letter is actually a number. How would I go about doing that?

So if I have records such as:

33 Acme Co.
1A Co.
Acme Co.

It should return both 33 and 1A.

rocknbil

6:34 pm on Sep 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try

select * from table where field regexp '^\d+.*';

MySQL uses standard regular expressions. The above means

^ begins with (first character on the line or in the field)
\d+ one or more digits
.* followed by zero or more of ANY character

Untested, but that should do it . . . .