SELECT tp1.o, tp2.o FROM rdf tp1 LEFT OUTER JOIN (SELECT s, o FROM rdf WHERE p='') tp2 ON (tp1.s=tp2.s) WHERE tp1.p='';