Environment: (PostgreSQL) 9.4.5
SELECT ARRAY ['foo', 'bar', 'hoge']AS fuga;
What should I do if I want to get only the middle bar from this array?
PHP-like
SELECT ARRAY ['foo', 'bar', 'hoge'][0]AS fuga;
If so,
ERROR: "[" or near it syntax error
I was scolded...
sql postgresql
It is true that [x]
can extract certain elements, but
Therefore, you can get bar
by doing the following:
SELECT(ARRAY['foo', 'bar', 'hoge')[2]AS fuga;
© 2024 OneMinuteCode. All rights reserved.