sqlpostgresqlcontainsltree

Search if a value exists in postgresql ltree


I am trying to check if a particular value exists in a list of ltree column. For example path column contains values {1.2.270, 1.270.3, 1.302.270.70}. I am trying to find if the value 270 exists in any of these 3 paths. But it is not working if I am using IN or ANY keywords.


Solution

  • Use documentation

    SELECT '{1.2.270, 1.270.3, 1.302.270.70}'::ltree[] ~ lquery('*.270.*')