mySQL INSERT INTO SELECT not working
Posted
by Industrial
on Stack Overflow
See other posts from Stack Overflow
or by Industrial
Published on 2010-05-08T13:46:29Z
Indexed on
2010/05/08
13:58 UTC
Read the original article
Hit count: 208
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?
© Stack Overflow or respective owner