2

I am basically trying to replicate functionality I know exists in MySQL. In MySQL it would look like:

 SUBSTRING_INDEX(p.url, 'selection=', -1)

How do I replicate this in PSQL?

Mihai
  • 26,325
  • 7
  • 66
  • 81
Spencer
  • 21,348
  • 34
  • 85
  • 121

1 Answers1

4
SELECT split_part(p.url, 'selection=', 2)...
Mihai
  • 26,325
  • 7
  • 66
  • 81
  • 2
    This only works for positive numbers, not negative numbers like in the OP. To select the last field, for example, use `reverse(split_part(reverse(p.url), 'selection=', 1))`. – expz Sep 22 '16 at 22:01