20

Is is possible to convert an enum declared in a postgresql schema to text so that I could use like clause for the enum column?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Blip
  • 3,061
  • 5
  • 22
  • 50

1 Answers1

31

You can cast the enum into text easily and use any textual operators on it.

SELECT * FROM table WHERE enumfield::TEXT LIKE 'Some%';

There might be a better way to handle what you want to achieve since the performance of this isn't the best.

Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74