2012/3/5 Cecil Westerhof <[email protected]>: > I am using the following SQL code: > CREATE TABLE container ( > containerID UUID PRIMARY KEY, > parentContainerId UUID, > description VARCHAR(50) NOT NULL, > > FOREIGN KEY(parentContainerID) REFERENCES (containerID) > ); > INSERT INTO container (containerID, description) VALUES > (random_UUID(), 'vriezer'); > INSERT INTO container ( > containerID, > parentContainerID, > description > ) VALUES ( > random_UUID(), > SELECT containerID FROM container WHERE description = 'vriezer', > 'bovenste lade' > ); > INSERT INTO container ( > containerID, > parentContainerID, > description > ) VALUES ( > random_UUID(), > SELECT containerID FROM container WHERE description = 'vriezer', > 'middelste lade' > ); > INSERT INTO container ( > containerID, > parentContainerID, > description > ) VALUES ( > random_UUID(), > SELECT containerID FROM container WHERE description = 'vriezer', > 'onderste lade' > ); > SELECT container.description AS container, > parent.description AS parentContainer > FROM container > LEFT JOIN container AS parent > WHERE container.parentContainerID = parent.containerID > > I would expect that all four containers would show up, with vriezer > 'having' parent NULL. But it does not. Only the four that do have a
I mend three instead of four. > parent show up. Is this a bug, or am I doing something wrong? > > Also: is there a better way to insert the containers that have as > parent 'vriezer'? -- Cecil Westerhof -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
