CREATE TABLE name (
  name_id INT NOT NULL PRIMARY KEY,
  name_text CHAR(35)
) \g

INSERT INTO name VALUES (1,'Teege')\g
INSERT INTO name VALUES (2,'Matthias')\g

CREATE TABLE pname (
  pname_id INT NOT NULL PRIMARY KEY,
  pname_name1 INT NOT NULL,
  pname_name2 INT
) \g

INSERT INTO pname VALUES (1,2,1)\g
INSERT INTO pname VALUES (2,1,1)\g

select pname.pname_id, name.name_text from
pname, name
where
pname.pname_name1 = name.name_id\g

select t1.pname_id, t2.name_text from
pname t1, name t2
where
t1.pname_name1 = t2.name_id\g

select t1.pname_id, t2.name_text, t3.name_text from
pname=t1, name=t2, name=t3
where
t1.pname_name1 = t2.name_id and
t1.pname_name2 = t3.name_id\g

drop table name\g
drop table pname\g

\q
