Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: mysql DBI Nested Queries

by CountZero (Bishop)
on Dec 23, 2012 at 14:00 UTC ( #1010096=note: print w/replies, xml ) Need Help??

in reply to mysql DBI Nested Queries

Unfortunately MySQL does not have recursive SQL capabilities, so the recursion will have to be done in Perl, which makes this kind of work rather slow since you will have to climb the adjacency tree node-by-node.

There are other solutions though, but they all mean that you will have to change your datatables. The most flexible and still fast model is probably the "closure table model". More info on the different options for hierarchical data models can be found at: Models for hierarchical data.


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010096]
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-06-18 02:41 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.