Update table - relation does not exist

user2990084

I am trying this query, however is not working: The idea is copy data from one table to another.

UPDATE  A
SET     A.name_en = B.name
FROM    country_name as A
        INNER JOIN country as B
            ON A.id = B.id

I am getting this error:

Error in query: ERROR: relation "a" does not exist
LINE 1: UPDATE A

Why?

Craig Ringer

You don't need the extra join here at all. You're doing an inner join so you can just do it with from and where clause instead:

UPDATE  country_name
SET     name_en = B.name
FROM    country AS B
WHERE   counry_name.id = B.id;

The only time you need to do the UPDATE sometable ... FROM sometable a ... WHERE sometable.id = a.id trick is when you need to do an outer join against the table being updated.

It's unfortunate that PostgreSQL's UPDATE ... FROM ... feature doesn't let you use explicit join syntax.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update join on postgresql - Relation does not exist

From Dev

Postgres reports that a relation does not exist, but the table exists

From Dev

Redshift ERROR: relation "Temp table" does not exist

From Dev

relation "table name" does not exist (postgresql)

From Dev

PostgreSQL check if table exist throwing "relation does not exist" error

From Dev

Relation *tablename* does not exist

From Dev

relation "old" does not exist

From Dev

Django: relation does not exist

From Dev

Relation does not exist PLPGSQL

From Dev

PostgreSQL ERROR: 42P01: relation "[Table]" does not exist

From Dev

Update table to insert new row if it does not exist

From Dev

A relation "table_name" does not exist in "Many2many relation" in Odoo 10.0

From Dev

LARAVEL : relation "table" does not exist LINE 1: select * from "table" ^ (SQL: select * from "table")

From Dev

django python - relation does not exist

From Dev

JPA ERROR: relation does not exist

From Dev

Django: Relation does not exist in Postgresql

From Dev

Django: Relation does not exist in Postgresql

From Dev

Relation does not exist error using WITH

From Dev

Django migrations: relation does not exist

From Dev

Update table only if value does not exist in a specific column

From Dev

Alembic: 'relation "public.alembic_version" does not exist' when using `version_table_schema`

From Dev

PGERROR: ERROR relation "table_name" does not exist (avoiding git commits)

From Dev

Why am I getting a "relation does not exist" error for existing table with sqlalchemy Metadata?

From Dev

update table if exist

From Dev

SQL Server : UPDATE Relation Table

From Dev

loopback hasandbelongstomany relation table doesn't exist

From Dev

Relation "table name" doesn't exist postgresql

From Dev

Rails: PG::UndefinedTable: ERROR: relation "..." does not exist

From Dev

Django + posgtres relation does not exist error

Related Related

  1. 1

    Update join on postgresql - Relation does not exist

  2. 2

    Postgres reports that a relation does not exist, but the table exists

  3. 3

    Redshift ERROR: relation "Temp table" does not exist

  4. 4

    relation "table name" does not exist (postgresql)

  5. 5

    PostgreSQL check if table exist throwing "relation does not exist" error

  6. 6

    Relation *tablename* does not exist

  7. 7

    relation "old" does not exist

  8. 8

    Django: relation does not exist

  9. 9

    Relation does not exist PLPGSQL

  10. 10

    PostgreSQL ERROR: 42P01: relation "[Table]" does not exist

  11. 11

    Update table to insert new row if it does not exist

  12. 12

    A relation "table_name" does not exist in "Many2many relation" in Odoo 10.0

  13. 13

    LARAVEL : relation "table" does not exist LINE 1: select * from "table" ^ (SQL: select * from "table")

  14. 14

    django python - relation does not exist

  15. 15

    JPA ERROR: relation does not exist

  16. 16

    Django: Relation does not exist in Postgresql

  17. 17

    Django: Relation does not exist in Postgresql

  18. 18

    Relation does not exist error using WITH

  19. 19

    Django migrations: relation does not exist

  20. 20

    Update table only if value does not exist in a specific column

  21. 21

    Alembic: 'relation "public.alembic_version" does not exist' when using `version_table_schema`

  22. 22

    PGERROR: ERROR relation "table_name" does not exist (avoiding git commits)

  23. 23

    Why am I getting a "relation does not exist" error for existing table with sqlalchemy Metadata?

  24. 24

    update table if exist

  25. 25

    SQL Server : UPDATE Relation Table

  26. 26

    loopback hasandbelongstomany relation table doesn't exist

  27. 27

    Relation "table name" doesn't exist postgresql

  28. 28

    Rails: PG::UndefinedTable: ERROR: relation "..." does not exist

  29. 29

    Django + posgtres relation does not exist error

HotTag

Archive