jpfarmer has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to run a select query against a mySQL database using the following code:
However, this returns no data. Even if I omit the variable and do this:my $filter = "('Y' || 'N')"; my $sth = $dbh->prepare(q{SELECT name FROM catagories WHERE catagories +.workrelated = ? ORDER BY name}); $sth->execute($filter);
I still get nothing. If I put the information in $filter directly into the prepare statement like this:my $sth = $dbh->prepare(q{SELECT name FROM catagories WHERE catagories +.workrelated = ? ORDER BY name}); $sth->execute("('Y' || 'N')");
Then the output is correct. What am I doing that confuses the DBI?my $sth = $dbh->prepare(q{SELECT name FROM catagories WHERE catagories +.workrelated = ('Y' || 'N') ORDER BY name}); $sth->execute();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Prepared query not accepting || instruction at execution
by dakkar (Hermit) on Dec 28, 2002 at 16:01 UTC | |
Re: Prepared query not accepting || instruction at execution
by bart (Canon) on Dec 28, 2002 at 16:58 UTC | |
Re: Prepared query not accepting || instruction at execution
by seattlejohn (Deacon) on Dec 28, 2002 at 20:11 UTC | |
Re: Prepared query not accepting || instruction at execution
by pfaut (Priest) on Dec 28, 2002 at 16:00 UTC | |
by jpfarmer (Pilgrim) on Dec 28, 2002 at 16:02 UTC | |
by CountZero (Bishop) on Dec 29, 2002 at 09:18 UTC |
Back to
Seekers of Perl Wisdom