1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Use LIKE with multiple names from a different table in UPDATE

Discussão em 'Outras Linguagens' iniciado por Stack, Julho 15, 2021.

  1. Stack

    Stack Membro Participativo

    I'm looking to update a field to a different value if the string in name contains a value from a different table in PostgreSQL:

    Table Types that needs to be updated

    id | name | type
    1 | Google Page | WEBSITE
    2 | Yahoo Page | WEBSITE
    3 | Facebook Page | WEBSITE
    ...


    Table Companies that has the names

    id | name
    1 | Google
    2 | Yahoo
    3 | Facebook
    4 | Twitter
    5 | Stackoverflow
    ...


    What I tried

    UPDATE types
    SET type = 'BUSINESS'
    WHERE name LIKE CONCAT((SELECT companies.name from companies), '% Page')


    But I'm getting this issue: [21000] ERROR: more than one row returned by a subquery used as an expression

    Continue reading...

Compartilhe esta Página