I have a table, for example writing in psql. This table has a column json (text type). It contains text like this:
writing:[{"variableName":variableValue ...}]
variableValues are different types, including text ,bigint and date.
I want to get all rows from writing where variableName has the value 2.
I'm using this select:
select * from writing where json::json->>'variableName' = '2' limit 5
This select returns me 0 rows, but there are a lot of data in this table, which should pass this condition. Any idea what is wrong, or maybe you have better statement.
Im using limit 5 because need just 5 rows.
jsonb, not astext. Then you would notice thatwriting:[{"variableName":variableValue ...}]is not a valid JSON value.