Set psql value from insert

Code examples

8
0

return insert results in POSTGRESQL

# to select specific columns
INSERT IGNORE INTO users (firstname, lastname) VALUES ('Joe', 'Cool') RETURNING id, firstname;
# to return every column
INSERT IGNORE INTO users (firstname, lastname) VALUES ('Joe', 'Cool') RETURNING *;
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 *

In other languages

This page is in other languages

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