1

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
  • 24,788
  • 7
  • 64
  • 78
Spencer
  • 19,732
  • 34
  • 83
  • 119

1 Answers1

3
SELECT split_part(p.url, 'selection=', 2)...
Mihai
  • 24,788
  • 7
  • 64
  • 78
  • 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