Skip to content

Instantly share code, notes, and snippets.

@igorpronin
Last active May 30, 2017 08:57
Show Gist options
  • Save igorpronin/08c4965696e284257d8f527f7a8ccd0d to your computer and use it in GitHub Desktop.
Save igorpronin/08c4965696e284257d8f527f7a8ccd0d to your computer and use it in GitHub Desktop.
Копировать выборочно данные из одной таблицы в другую
--example 1
INSERT INTO cheap_books (id, note)
SELECT id, 'Was in use'
FROM Books WHERE id > (SELECT MAX(id) FROM Books) - 3
--example2
INSERT INTO public.table1 (id_user, id_operator, status)
SELECT field1, 'field2', '300'
FROM tmp.table2 WHERE id = 33951632290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment