I have two tables, one is about the selling, and another table contains the information about the vehicle:
CREATE TABLE vehicle
(
    id                    SERIAL PRIMARY KEY,
    specs_id              INT REFERENCES specs (id) ON DELETE RESTRICT,
    model                 INT REFERENCES model (id) ON DELETE RESTRICT,
    delivery_date         DATE,
    color                 VARCHAR(20),
    plant_id              SERIAL REFERENCES plant (id) ON DELETE RESTRICT,
    date_of_manufacturing DATE
);
CREATE TABLE selling
(
    vehicle      INT REFERENCES vehicle (id) ON DELETE RESTRICT,
    client_id    INT REFERENCES client (id) ON DELETE RESTRICT,
    VIN          CHAR(17) PRIMARY KEY NOT NULL,**
    selling_date DATE,
    subtotal     INTEGER,
    payment      PAYMENT_TYPE,
    seller_id    INT REFERENCES manager (id) ON DELETE RESTRICT
);
I need to move field VIN from selling to vehicle, and I need the existing vehicles to correspond with thier VINs. Here is the table: The tables to modify
I have tried this code:
ALTER TABLE vehicle
ADD COLUMN VIN CHAR(17);
UPDATE vehicle VIN
SET VIN = selling.VIN
FROM selling
But the result is wrong: all the vehicles get the one VIN from selling:
 
    