[GRASS-user] SQL and GRASS

Message: 6
Date: Sun, 7 Mar 2010 06:02:51 -0800 (PST)
From: Gary Nobles <garynobles@yahoo.com>
Subject: [GRASS-user] SQL and GRASS
To: grass-user@lists.osgeo.org
Message-ID: <1267970571671-4690410.post@n2.nabble.com>
Content-Type: text/plain; charset=us-ascii

GRASS is connected to a MySQL data base

I want to select polygons which are not 0
so do I do:

d.vect SiteGrid3 where "SquareNumber<>0 "
or
v.db.select map=SiteGrid3 column=square_no where=<>0

I have a second non spatial table described below(right)

grass SiteGrid3 (one) Pottery table (many)
|cat|SquareNumber| |SquareNumber|Type|
|1 |1 | |1 |mug |
|2 |2 | |1 |mug |
|3 |3 | |1 |mug |
it continues...

so now I want to select the square number but be able to use v.what to
return the amount of pottery.

Any ideas? This is easy in sql but I want to show it in GRASS

Thanks

Gary
  
Gary,

Easy.

d.vect SiteGrid3 where="SquareNumber<>0"
or
v.db.select map=SiteGrid3 column=square_no where="square_no<>0"

In Grass-GIS, "where" statements are generally followed by the equals sign, then the statement.

Richard C

Hi Richard,

Thankyou for your help, I have been using:

d.vect SiteGrid3 where "SquareNumber<>0 "
or
v.db.select map=SiteGrid3 column=square_no where=<>0

however as you see in my example in my initial post I have a second table:

grass SiteGrid3 (one) Pottery table (many)
|cat|SquareNumber| |SquareNumber|Type|count|
|1 |1 | |1 |mug |12
|2 |2 | |1 |mug |14
|3 |3 | |1 |mug |3
it continues...

d.vect SiteGrid3 where "SquareNumber<>0 " is great for table1 (left) but I
want to query a non spatial table, the pottery table. So I want to display
all squares where Pottery.Type ='mug'

and also:

display: select SiteGrid3.SquareNumber, Pottery.SUM(count) from SiteGrid3,
Pottery

I may need an inner join so like this

select SiteGrid3.SquareNumber, Pottery.SUM(count)
from SiteGrid3, Pottery
Inner JOIN SiteGrid3
ON Pottery.SquareNumber=siteGrid3.SquareNumber
where (possible where statement)

so displaying data based on a complex sql statement

I hope this clarifies my problem

Thanks again

Gary

--
View this message in context: http://n2.nabble.com/SQL-and-GRASS-tp4690410p4714753.html
Sent from the Grass - Users mailing list archive at Nabble.com.