Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: mysql DBI Nested Queries

by Anonymous Monk
on Dec 24, 2012 at 15:53 UTC ( #1010205=note: print w/replies, xml ) Need Help??


in reply to mysql DBI Nested Queries

A simplified iterative approach, provided in pseudocode. Assumes supervisor is empty or null when hits CEO level. (Adjust while condition if not a good assumption.)

my $supervisor = $initial_employee_id; while ($supervisor) ( $row = select columns where eid = $supervisor; print out spreadsheet row for employee; $supervisor = $row{supervisor}; }

Also, since the database only returns a single row, you should be able to use the selectrow_arrayref function to make your sql code a bit simpler. And as for your "how to use variable inside sql string" question, see 7548

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010205]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-07-21 19:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (450 votes). Check out past polls.

    Notices?