sql - PostgreSQL get last value in a comma separated list of values -


in postgresql table have column has values

ax,b,c a,bd x,y j,k,l,m,n 

in short , have few comma separated strings in column each record. wanted last 1 in each record. ended this.

select id, reverse(substr(reverse(mycolumn),1,position(',' in reverse(mycolumn)))) mytable order id ;  

is there easier way?

with regexp_replace:

select id, regexp_replace(mycolumn, '.*,', '') mytable order id; 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -