Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select rows which start with digit in PostgreSQL?

Tags:

sql

postgresql

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.

like image 922
noxvile Avatar asked Apr 18 '10 11:04

noxvile


1 Answers

Try this:

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

This uses a POSIX regular expression.

like image 132
Mark Byers Avatar answered Sep 18 '22 15:09

Mark Byers