order by JSON data type postgres

后端 未结 3 1008
甜味超标
甜味超标 2021-02-03 23:07

I have a Postgres table which has column of type JSON which has a bunch of JSON objects in them. I want to query the table records and order the results by a value stored in the

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 23:53

    Use -> instead of ->> (->> gets a JSON object field as text):

    select * from my_table ORDER BY data->'some_number' asc; 
    

提交回复
热议问题