sqlpostgresqlpostgresql-9.1

How to use SQL LIKE condition with multiple values in PostgreSQL?


Is there any shorter way to look for multiple matches:

 SELECT * 
 from table 
 WHERE column LIKE "AAA%" 
    OR column LIKE "BBB%" 
    OR column LIKE "CCC%"

This questions applies to PostgreSQL 9.1, but if there is a generic solution it would be even better.


Solution

  • Perhaps using SIMILAR TO would work ?

    SELECT * from table WHERE column SIMILAR TO '(AAA|BBB|CCC)%';