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?

4
  • And your question is...? Commented Dec 18, 2015 at 21:55
  • How do I do the same thing PSQL... Commented Dec 18, 2015 at 21:55
  • Do you have a fixed number of 'selection=' delimiters in that column? Commented Dec 18, 2015 at 21:58
  • there will be either 1 or 0. Commented Dec 18, 2015 at 22:01

1 Answer 1

4
SELECT split_part(p.url, 'selection=', 2)...
Sign up to request clarification or add additional context in comments.

1 Comment

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)).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.