Searching substring in PostgreSQL

前端 未结 3 2025

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:55

    (Note: This answer was written before further discussion clarified the poster's actual intentions)

    It would appear highly likely that there is more than one str in test where str IS NOT NULL. That's why more than one row is returned by the subquery used as an expression, and, thus, why the statement fails.

    Run the subquery stand-alone to see what it returns and you'll see. Perhaps you intended it to be a correlated subquery but forgot the outer column-reference? Or perhaps there's a column also called str in the outer table and you meant to write:

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

    ?

    (Hint: Consistently using table aliases on column references helps to avoid name-clash confusion).

提交回复
热议问题