Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The following SQL statement works but is not working in the way I need it to.
I'm using IN to only bring back fields that have the engine name found in @choices (which populates properly). But it brings back everything that meets the OTHER critera, too. Like it'll bring back anything that has settings1-4 that are public, even if the name for @choices wasn't found.my $data = qq(SELECT engine, name1, name2, name3, name4, lable1, l +able2, lable3, lable4, settings1, settings2, settings3, settings4 FROM special_fields WHERE engin +e IN (".join(",",map($dbh->quote($_), @choices)).") AND settings1="public" OR settings2="public" OR settings +3="public" OR settings4="public");
My guess is my IN, ANDS, ORS are contradicting each other. I need it so it only brings back the records if IN name is found in @choices and at least one of the settings1-4 are set to "public".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: in, ands, ors in query
by rhesa (Vicar) on Dec 13, 2006 at 01:22 UTC | |
by Anonymous Monk on Dec 13, 2006 at 01:34 UTC | |
by tye (Sage) on Dec 13, 2006 at 01:44 UTC | |
by Anonymous Monk on Dec 13, 2006 at 03:18 UTC | |
by tye (Sage) on Dec 13, 2006 at 03:29 UTC | |
| |
by chromatic (Archbishop) on Dec 13, 2006 at 01:44 UTC | |
|
Re: in, ands, ors in query ()
by tye (Sage) on Dec 13, 2006 at 01:22 UTC | |
|
Re: in, ands, ors in query
by graff (Chancellor) on Dec 13, 2006 at 02:50 UTC | |
by jdporter (Paladin) on Dec 13, 2006 at 16:50 UTC | |
|
Re: in, ands, ors in query
by davidrw (Prior) on Dec 13, 2006 at 16:04 UTC |