[GRASS-user] SQL query

Hamish hamish_b at yahoo.com
Fri Jan 8 12:20:31 EST 2010


Hi,

I have a bunch of maps in the same mapset with identical table structure
and with similar sounding names. With v.to.db I've uploaded a distance to
each of their 'length' columns.

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

Now I want to print them all out in a single command.

I tried this, but it doesn't work:

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



this works:

db.select sql="SELECT length FROM track_001 \
         UNION SELECT length FROM track_002 \
         UNION SELECT length FROM track_003"

but I have something like 100 maps and the statement would get too huge.


any hints?


thanks,
Hamish


More information about the grass-user mailing list