Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
What is wrong in the following?
my $value1="query"; my $value2="%"; my $selection = $dbh->selectall_arrayref("SELECT Tag1, Tag2, Term1, Te +rm2 FROM table WHERE Tag1 LIKE '$value' AND Tag2 LIKE '$value2' ");
What I am trying to do: My query has sometimes a $value2, sometimes $value2 just doesn't need to be used. I want to avoid to have 2 different contructions of $selection, the first with one codition and the second with 2 conditions ... to keep my code shorter and cleaner.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI SQLite statement problem with %
by runrig (Abbot) on Mar 22, 2016 at 17:18 UTC | |
by Your Mother (Archbishop) on Mar 22, 2016 at 19:05 UTC | |
|
Re: DBI SQLite statement problem with %
by Corion (Patriarch) on Mar 22, 2016 at 15:40 UTC | |
|
Re: DBI SQLite statement problem with %
by Pope-O-Matik (Pilgrim) on Mar 23, 2016 at 13:21 UTC | |
|
Re: DBI SQLite statement problem with %
by soonix (Chancellor) on Mar 23, 2016 at 09:15 UTC |