-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE u (
    uid INTEGER,
    name VARCHAR(20),
    PRIMARY KEY(uid)
);

CREATE TABLE ref (
    rid INTEGER,
    uid INTEGER,
    PRIMARY KEY(rid)
);

INSERT INTO u VALUES(1,'A A');
INSERT INTO u VALUES(2,'B B');

INSERT INTO ref VALUES(1,1);
INSERT INTO ref VALUES(2,1);
INSERT INTO ref VALUES(3,1);
INSERT INTO ref VALUES(4,2);
INSERT INTO ref VALUES(5,2);

SELECT * FROM u LEFT JOIN ref ON u.uid=ref.uid;

DROP TABLE u;
DROP TABLE ref;
