I have two tables tablle - bm id SERIAL PK, est_nom INT, nom VARCHAR(70) CONSTRAINT FK_bm_est FOREIGN KEY(est_nom) REFERENCES est(est_id) ON DELETE SET NULL table - est est_id SERIAL PK, est_nom VARCHAR(70) i want to insert this data in bm INSERT INTO bm VALUES (netx serial,'DAPR','leopold stotch'), (netx serial,'LDGA','fredderik gauss'), (netx serial,'SDCD','edward gortz') but in column 2, est. They are not int. I want to look for those values in the est table in the est_nom column and if it finds it, give me its est_id. and insert it in bm.est_id And if it doesn't find it, insert that data in the est table in the est_nom column and assign it a consecutive serial number. Then now I inserted it into bm with its new serial number.