[GRASS-user] SQL query

Rich Shepard rshepard at appl-ecosys.com
Fri Jan 8 13:40:13 EST 2010


On Sat, 9 Jan 2010, Hamish wrote:

> The DB is SQLite and everything is stored in $MAPSET/sqlite.db.

> G65> db.select sql="SELECT length FROM table_name LIKE 'track_%'"

Hamish,

   The problem is with SQL syntax; at least with SQLite. As Rick van der Lans
notes in his "The SQL Guide to SQLite", "Because this literal comes after a
LIKE operator and not after a comparison operator, two characters, the
percentage sign and the underscore, have a special meaning. Such a literal
is called a pattern or a mask. In a pattern, the percentage sign stands for
zero, one, or more characters. The underscore stands for exactly one random
character."

   Therefore, when you specify the individual name it works, but in the above
you're asking for exactly one character followed by zero or more characters.

HTH,

Rich


More information about the grass-user mailing list