I want to fetch the instrumenttype from instruments column the data sample is
[‘{instrumenttype=Index}’].
please find attached snap for more details..
I have tried select instruments1.instrumentype from TABLE_NAME;
did not get result.
kindly help me for the same.
You can either use the JSON accessor operator ->>
:
<code>SELECT instruments -> 'instrumenttype' FROM tab;
</code>
<code>SELECT instruments -> 'instrumenttype' FROM tab;
</code>
SELECT instruments -> 'instrumenttype' FROM tab;
or use this equivalent syntax:
<code>SELECT instruments['instrumenttype'] FROM tab;
</code>
<code>SELECT instruments['instrumenttype'] FROM tab;
</code>
SELECT instruments['instrumenttype'] FROM tab;
Note that the result is of type json
or jsonb
. If you want the result as a string, either use a type cast or the ->>
operator:
<code>SELECT instruments ->> 'instrumenttype' FROM tab;
</code>
<code>SELECT instruments ->> 'instrumenttype' FROM tab;
</code>
SELECT instruments ->> 'instrumenttype' FROM tab;