Skip to content

Instantly share code, notes, and snippets.

@esmevane
Created January 19, 2014 20:54
Show Gist options
  • Select an option

  • Save esmevane/8510881 to your computer and use it in GitHub Desktop.

Select an option

Save esmevane/8510881 to your computer and use it in GitHub Desktop.
burrito-tropical=# select * from labels;
id | message_id | account_id | content | created_at | updated_at
-----+------------+------------+--------------------------------+------------+------------
441 | | | {1} | |
442 | | | {Inbox,Unread} | |
443 | | | {Inbox} | |
444 | | | {Request,Inbox,Papaya,Burrito} | |
445 | | | {Request,Inbox,Papaya,Burrito} | |
446 | | | {Request,Inbox,Papaya,Burrito} | |
447 | | | {Request,Burrito} | |
(7 rows)
burrito-tropical=# update labels
burrito-tropical-# set content = (select array_agg(x)
burrito-tropical(# from (select unnest(content) as x) sq_1
burrito-tropical(# where not x = 'Request')
burrito-tropical-# where content @> '{Request}';
UPDATE 4
burrito-tropical=# select * from labels;
id | message_id | account_id | content | created_at | updated_at
-----+------------+------------+------------------------+------------+------------
441 | | | {1} | |
442 | | | {Inbox,Unread} | |
443 | | | {Inbox} | |
444 | | | {Inbox,Papaya,Burrito} | |
445 | | | {Inbox,Papaya,Burrito} | |
446 | | | {Inbox,Papaya,Burrito} | |
447 | | | {Burrito} | |
(7 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment