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

Re: Place holders in SQL query

by mje (Curate)
on Oct 10, 2014 at 15:03 UTC ( #1103427=note: print w/replies, xml ) Need Help??


in reply to Place holders in SQL query

Not saying it is best but you could do this. Change your map to be 'map {"state=?"} @$citydata'. Then pull the states out of @$citydata and into an array and pass this array to the exec_select().

Replies are listed 'Best First'.
Re^2: Place holders in SQL query
by Anonymous Monk on Oct 10, 2014 at 15:14 UTC
    Thats where I am stuck; "Then pull the states out of @$citydata and into an array and pass this array to the exec_select()"
      my @states = map {$_->{state}} @$citydata; . . exec_select(sql, @states);
        It worked!
        my $citydata = $dbh->exec_select( "select city,state from mytable whe +re city = ?", $city ); my @states = map {$_->{state}} @$citydata; my $statedata = join ' OR ', map { "state = ?" } @$citydata; my $codedata = $dbh->exec_select( "select code from othertable where +(year=2014 and ($statedata)), @states );

        Thanks for the help!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1103427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2019-06-17 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (80 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!