Search code examples
sqlpostgresqlsql-viewempty-list

SQL SELECT WHERE meta_keywords = '['']'


I have been having trouble query after '['']' in table. The data is inserted from pandas dataframe with datatype object (if it matters).

A picture of a view of the table

I want to get make a view without the empty lists. Have tried to write the empty list different ways '['']' , '["''"]' etc. but i cant get it to work. ex where meta_keywords <> '['']'


Solution

  • If meta_keywords is a string, you would use:

    where meta_keywords <> '['']'
    

    or:

    where meta_keywords <> '['''']'
    

    Or perhaps it is hard to tell what those middle characters really are and you can use the length:

    where length(meta_keywords) > 4
    

    If it is an array (which I am guessing), then one of these might work:

    where cardinality(meta_keywords) > 0
    

    or:

    where '' <> meta_keywords[1] and cardinality(meta_keywords) = 1