How to preserve the original order of elements in an unnested array?
-
30-10-2019 - |
题
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
没有正确的解决方案
不隶属于 dba.stackexchange