Sample Header Ad - 728x90

How to preserve the original order of elements in an unnested array?

26 votes
1 answer
27622 views
Given the string: > 'I think that PostgreSQL is nifty' I would like to operate on the individual words found within that string. Essentially, I have a separate from which I can get word details and would like to join an unnested array of that string on this dictionary. So far I have: select word, meaning, partofspeech from unnest(string_to_array('I think that PostgreSQL is nifty',' ')) as word from table t join dictionary d on t.word = d.wordname; This accomplishes the fundamentals of what I was hoping to do, but it does not preserve the original word order. Related question: PostgreSQL unnest() with element number
Asked by swasheck (10755 rep)
Oct 19, 2012, 08:00 PM
Last activity: May 15, 2024, 08:26 PM