tags:

views:

35

answers:

2

Need to get rows starting with digit e.g. '1test', '32 test'. I tried

SELECT * FROM table WHERE name LIKE '[0-9]%'

as I used to do in MSSQL but it wasn't successful.

+4  A: 

Try this:

SELECT * FROM table WHERE name ~ '^[0-9]'

This uses a POSIX regular expression.

Mark Byers
+4  A: 

According to the docs, you can use SIMILAR TO instead of LIKE to do regex-like matching, and ~ to do full POSIX regex matching.

Max Shawabkeh