Searching substring in PostgreSQL

前端 未结 3 2062

I have a POstgreSQL 8.4. I have a table and i want to find a string in one row (character varying datatype) of this table using substring (character varying datatype) returned b

3条回答
  •  天命终不由人
    2021-01-24 02:51

    Use like any :

    SELECT  uchastki.kadnum
    FROM  uchastki
    WHERE kadnum LIKE  ANY(
       SELECT str
       FROM test
    WHERE str IS NOT NULL)
    

    Or perhaps:

    SELECT  uchastki.kadnum
    FROM  uchastki
    WHERE kadnum LIKE  ANY(
       SELECT '%' || str || '%'
       FROM test
    WHERE str IS NOT NULL)
    

    this is a nice feature, You can use different operators, for example = any (select ... ), or <> all (select...).

提交回复
热议问题