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

[SQL] Select a value from a table using table column key

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 25, 2024 às 11:23.

  1. Stack

    Stack Membro Participativo

    I have the following Postures table:

    CREATE TABLE users
    (
    id bigint NOT NULL,
    created_by character varying(255) COLLATE pg_catalog."default",
    creation_date timestamp(6) without time zone,
    default_travel_method_id character varying(255) COLLATE pg_catalog."default",
    default_shipping_address_id character varying(255) COLLATE pg_catalog."default",
    CONSTRAINT users_pkey PRIMARY KEY (id)
    )


    When I use this select to select also a column from another table I use this in Oracle:

    SELECT
    created_by,
    (select reference from methods where id = default_travel_method_id) as default_travel_id,
    (select reference from addresses where id = default_shipping_address_id) as defaultShippingAddressId,
    from users;


    But in Postures I get this error:

    ERROR: operator does not exist: bigint = character varying
    LINE 8: ...reference from methods where id = default_...
    ^
    HINT: No operator matches the given name and argument types. You might need to add explicit type casts.


    Do you know in Postgres what is the proper way to use a column expression to select a value from another table?

    Continue reading...

Compartilhe esta Página