[GRASSLIST:10279] joining attribute tables using SQL commands

j b jessi_issej at hotmail.com
Mon Feb 13 15:11:29 EST 2006


hello.
I am a beginner trying to join attribute tables.

To be more specific, I have a .dbf table called streetcl, which gives street
blocks and their various attributes. It contains an attribute called FNODE_,
which is the ID of its starting intersection. I used the command:

echo "ALTER TABLE streetcl ADD COLUMN ELEVFROM double" | db.execute

to create an attribute called ELEVFROM. In this column, i want to put the
elevation of the intersection where each block originates. I have another
.dbf table called intersect which gives the city's intersections; it has a 
column called ELEV (the intersection's elevation) and a column called 
STREETCL_ (the ID of the
intersection as referred to in the streetcl table.)

This seems like it should not be so complicated, but i'm getting SQL parser 
errors.

My first attempt was this command:

echo "UPDATE streetcl SET ELEVFROM=(SELECT ELEV FROM intersect WHERE
intersect.STREETCL_=streetcl.FNODE_)" | db.execute

This tells me:
DBMI-DBF driver error:
SQL parser error in statement:
...

Then, to test, I tried to do more simple commands. I created a column in
streetcl called TEST, and tried to set it equal to another column (same 
type)
in streetcl, called LENGTH.

echo "UPDATE streetcl SET TEST=LENGTH" | db.execute

this gives me the same error. A command like:

echo "UPDATE streetcl SET TEST=30" | db.execute

is fine, but even:
echo "UPDATE streetcl SET TEST=30+2" | db.execute
(with or w/out parens around "30+2) gives me the same SQL parser error.

Any idea what is going on? Am i even going about this in the right way?
Should i be using SQL commands or is there another approach entirely?
thanks very much.
jessi




More information about the grass-user mailing list