pgunn=# \d entities Table "entities" Column | Type | Modifiers --------+------------------------+------------------------------------------------------ eid | integer | not null default nextval('"entities_eid_seq"'::text) name | character varying(120) | Primary key: entities_pkey Unique keys: entities_name_key pgunn=# \d friends Table "friends" Column | Type | Modifiers --------+---------+------------------------------------------------------ e1 | integer | not null e2 | integer | not null rank | integer | not null default nextval('"friends_rank_seq"'::text) Unique keys: friends_rank_key pgunn=# select rank,eid from friends,entities where friends.e1 = entities.eid;