[GRASS-user] updating table values from another table

Moritz Lennert mlennert at club.worldonline.be
Tue May 13 18:22:23 EDT 2008


On 13/05/08 16:38, Manuel Seeger wrote:
> Hello all,
> 
> 
> I want to update the values of selected columns in one vector file with 
> the values from another.  I think v.db.update should be the right thing, 
> but I don't know ho to do it (using the dbf driver)
> 
> Perhaps someone helps me?

This really depends on which backend you are using. If you use dbf data 
files, the only way to do it would be v.db.join to join the complete 
tables together as dbf tables are not "conscious" of each other.

If you use another backend (e.g. PostgreSQL or SQLite), the easiest 
would probably to do this directly in the database, without going 
through GRASS. The SQL would be something like this:

UPDATE A SET name = B.name FROM B WHERE A.id = B.id

However, you can also use db.execute:

echo "UPDATE A SET name = B.name FROM B WHERE A.id = B.id" | db.execute

or put into the SQL into file and call db.execute with the file= parameter.

Moritz


More information about the grass-user mailing list