by koolba · 6y ago · 0 comments
SELECT json_content ##> {person, last_name} FROM mytable;
> The #> or #> is the JSON path navigator with the difference being #> returns JSON and the ##> returns the JSON text value.That should be #>> (two ">"), not ##> (two "#").
The official docs are really good and they include a number of inline examples showing the difference between the operators: https://www.postgresql.org/docs/current/functions-json.html
The bottom example is missing a colon on the cast as well:
> SELECT json_content FROM mytable WHERE json_content @> '{"status": "Awesome"}':jsonb;
Should be two colons ("::") for an explicit cast: '{"status": "Awesome"}'::jsonb
(I’m happy we don’t have to write queries in yaml, only half joking.)
https://www.sqlite.org/json1.html
https://dev.mysql.com/doc/refman/8.0/en/json-function-refere...
https://docs.microsoft.com/en-us/sql/t-sql/functions/json-fu...
(Too bad there was no standard for these.)