Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
I am trying to add place holders to a SQL query, but I am formatting the second query based on a first SQL query.
The code sample here shows what I am trying to do, if its possible:
Any help?
Thanks for looking!
I am trying to add place holders to a SQL query, but I am formatting the second query based on a first SQL query.
The code sample here shows what I am trying to do, if its possible:
# The first SQL query to get the state value<br> my $citydata = $dbh->exec_select( "select city,state from mytable wher +e city = ?", $city ); # This one gets me all the values found for state my $statedata = join ' OR ', map { "state = $_->{ state}" } @$citydata +; # Now $statedate gets this: “state = NH OR state = NY”. # I would like to add place holders and pass these values into the sec +ond query # To read like “state = ? OR state ?” my $codedata = $dbh->exec_select( "select code from othertable where + (year=2014 and ($statedata)), $citydata->{state},$citydata->{state} + );
Any help?
Thanks for looking!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Place holders in SQL query
by poj (Abbot) on Oct 10, 2014 at 16:07 UTC | |
Re: Place holders in SQL query
by McA (Priest) on Oct 10, 2014 at 16:26 UTC | |
Re: Place holders in SQL query
by mje (Curate) on Oct 10, 2014 at 15:03 UTC | |
by Anonymous Monk on Oct 10, 2014 at 15:14 UTC | |
by mje (Curate) on Oct 10, 2014 at 15:41 UTC | |
by Anonymous Monk on Oct 10, 2014 at 17:43 UTC | |
Re: Placeholders in SQL query
by erix (Prior) on Oct 10, 2014 at 15:17 UTC | |
by hippo (Bishop) on Oct 10, 2014 at 16:09 UTC | |
by Anonymous Monk on Oct 10, 2014 at 15:31 UTC | |
by Anonymous Monk on Oct 10, 2014 at 15:28 UTC | |
by Anonymous Monk on Oct 11, 2014 at 03:21 UTC |
Back to
Seekers of Perl Wisdom