Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ba66de593b98ad0d6e4a to your computer and use it in GitHub Desktop.
Save anonymous/ba66de593b98ad0d6e4a to your computer and use it in GitHub Desktop.
psql (9.4.1)
Type "help" for help.
test=# create table bug_or_feature (id bigserial not null primary key, foo text not null);
CREATE TABLE
test=# insert into bug_or_feature (foo) values ('bar');
INSERT 0 1
test=# insert into bug_or_feature (foo) values ('bar');
INSERT 0 1
test=# insert into bug_or_feature (foo) values ('bar');
INSERT 0 1
test=# update bug_or_feature set foo = 'baz' from (select id from bug_or_feature where foo = 'bar' limit 1) as yada;
UPDATE 3
test=# select * from bug_or_feature;
id | foo
----+-----
1 | baz
2 | baz
3 | baz
(3 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment