indigoviolet has asked for the wisdom of the Perl Monks concerning the following question:
works correctly, this doesn't:$db->query( 'SELECT * from thistable WHERE position <= ?', $position )->flat()
Could someone enlighten me, please?$db->query( 'SELECT * from thistable WHERE position - 1 <= ?', $position )->flat();
235 163 163 415 415 306 415 235 270 ...This returns 9 values of 'position':
This returns 71,828 values of 'position', ie all the rows in the table: Note that the answer should be the same, 9 matching rows.$position = 500; $db->query( 'SELECT position from thistable WHERE position <= ?', $position )->flat()
Placeholders on the LHS This works, though:$position = 500; $db->query( 'SELECT position from thistable WHERE (position-1+1) <= ?', $position )->flat()
And finally, I've tried DBI directly instead of DBIx::Simple, and still see this. (thanks to virtualsue for comments on making this more informative)$db->query( "SELECT position from thistable WHERE (position- ?) <= 500", 1 )->flat +()
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI placeholders and expressions
by talexb (Chancellor) on Sep 24, 2006 at 15:43 UTC | |
by indigoviolet (Acolyte) on Sep 25, 2006 at 06:35 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |