postgresql - Postgres Select Where JSON Field Not Null -


i have table has column called warnings. column value 2 rows shown bellow

                             warnings -------------------------------------------------------------------  {"isnew":false,"fieldwarnings":[],"dupid":null,"conflictids":[]}  {"isnew":false,"fieldwarnings":[],"dupid":3763,"conflictid":null} 

i want sql statement select top row not bottom row. tried sql query selects both rows

select warnings table cast(warnings->>'dubid' text) null; 

you have dubid in query json property dupid. think you've got typo!

try instead:

select warnings table cast(warnings->>'dupid' text) null; 

also, ->> operator returns field value text shouldn't need cast:

select warnings table warnings->>'dupid' null; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -