-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
CREATE TABLE nullfun(
    id INTEGER AUTO_INCREMENT PRIMARY KEY,
    dollaralder INTEGER,
    alder INTEGER
);

INSERT INTO nullfun(dollaralder,alder) VALUES(NULL,NULL);
INSERT INTO nullfun(dollaralder,alder) VALUES(NULL,20);
INSERT INTO nullfun(dollaralder,alder) VALUES(20,NULL);
INSERT INTO nullfun(dollaralder,alder) VALUES(20,30);
INSERT INTO nullfun(dollaralder,alder) VALUES(30,20);
INSERT INTO nullfun(dollaralder,alder) VALUES(25,25);

SELECT * FROM nullfun ORDER BY id;

SELECT dollaralder,alder,IF(alder IS NULL OR dollaralder IS NULL,IF(dollaralder IS NULL,true,false),alder<dollaralder) FROM nullfun;

DROP TABLE nullfun;
