[GRASS-user] SQL query

Hamish hamish_b at yahoo.com
Fri Jan 8 17:22:34 EST 2010


Hamish wrote:
> > G65> db.select sql="SELECT length FROM table_name LIKE 'track_%'"
>
> DBMI-SQLite driver error:
> Error in sqlite3_prepare():SELECT length FROM table_name LIKE 'track_%'
> near "'track_%'": syntax error


Rich wrote:
> ... "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.


which is exactly what I want, a wildcard match track_001,
track_002, etc. The underscore is along for the ride in this
case, but escaping chars is a pain in sql and in this case I
know it is not likely to harm.

what is the syntax error?


thanks,
Hamish



      


More information about the grass-user mailing list