mySQL INSERT INTO SELECT not working
- by Industrial
Hi everyone,
I am trying to implement the "Closure Table" structure in a php/mySQL webapp from Bill Karwins "SQL Antipatterns" slideshare presentation: http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back
The first step is to insert some stuff into my tree (page 73 in slide):
Easy to insert a new child of comment #5:
INSERT INTO Comments ... (Generates comment #8)
INSERT INTO TreePaths (ancestor, descendant)
VALUES (8, 8);
INSERT INTO TreePaths (ancestor, descendant)
SELECT ancestor, 8 FROM TreePaths
WHERE descendant = 5;
I try to translate all this into Codeigniters active record db-style language, and that's about where I get stuck. I cant understand how the second insert gets it's values.
Is there anyone out there who can help me out with this?