查询 Char 不同的 postgres

Query Char varying postgres

我一直在尝试使以下查询有效,但我做不到:

   SELECT "users".* FROM "users" WHERE (users.roles LIKE "%sales%")
or
   SELECT "users".* FROM "users" WHERE (users.roles LIKE '%sales%')

其中角色,可以包含:

 {operations,business_development,sales,customer_service,manager}

角色是:character varying[]

我遇到错误:

ERROR: operator does not exist: character varying[] ~~ unknown LINE 1: select users.id from users where users.roles LIKE '%sales%'...

尝试

SELECT "users".* FROM "users" WHERE  'sales' = ANY(users.roles) 

话虽如此,值得注意的是:

Tip: Arrays are not sets; searching for specific array elements can be a sign of database misdesign. Consider using a separate table with a row for each item that would be an array element. This will be easier to search, and is likely to scale better for a large number of elements.

http://www.postgresql.org/docs/9.5/static/arrays.html