User Tools

Site Tools


postgres:copy_command

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
postgres:copy_command [2013/07/26 09:06]
mh
postgres:copy_command [2014/09/10 21:22] (current)
Line 13: Line 13:
  count  count
 ----- -----
 +
 +world=# create table countries_x_organisations (code character(3),​ organisation_id integer);  ​
 +
 +world=# insert into organisations (id, name) values (nextval('​world_seq'​),​ '​Euro'​);  ​
 +world=# insert into organisations (id, name) values (nextval('​world_seq'​),​ '​EU'​);  ​
 +
 +world=# insert into countries_x_organisations (code, organisation_id)
 +world-# select code, (select id from organisations where name = '​EU'​) from countries where name in (select state from membership_raw where eu = '​EU'​);​
 +
 +
 +world=# select c.name, o.name from countries c join countries_x_organisations cxo
 +        on cxo.code = c.code join organisations o on o.id = cxo.organisation_id;​
 +
 +</​code>​
 +
 +
postgres/copy_command.1374822399.txt.gz ยท Last modified: 2014/09/10 21:22 (external edit)