[GRASSLIST:10298] Re: joining attribute tables using SQL commands

j b jessi_issej at hotmail.com
Tue Feb 14 08:03:00 EST 2006


Hello.
thanks for the help. what about using ogr2ogr, or ogrinfo? i have both of 
these running on my computer, but was also getting SQL parser errors when i 
tried pretty simple SQL commands. is it just an extremely simplified version 
of SQL?
i can also try using sqlite----i tried that earlier looking at that previous 
post, but i'll give it another try. i'll still have .dbf files at the end if 
i manipulate them with the sqlite driver, right?
thanks again,
jessi


>
>Hi Jessi,
>unfortunately, it is not possible to join tables with the dbf-driver. 
>However,
>if you use sqlite, Postgres or Mysql it's possible. There is an example for
>sqlite on this list:
>
>--> 
>http://article.gmane.org/gmane.comp.gis.grass.user/10882/match=sqlite+join
>
>Best regards,
>
>Wolfgang
>
>--
>
>Am Montag 13 Februar 2006 pH:11:21 nachmittags/abends schrieb j b:
> > 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