Insert into table if value exists in another table postgresql

Code examples

1
0

POSTGRES INSERT IGNORE INTO TABLE VALUE FROM OTHER TABLE

##fetch data from other table with sub-query to insert it into another one

INSERT IGNORE INTO PUBLIC."MyTable"(conversion_job_id, message, last_status)
VALUES (17, 'test', (SELECT status FROM PUBLIC."OtherTable" WHERE id=17))
RETURNING *

Similar pages

Similar pages with examples

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................