Skip to main content
deleted 31 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I am looking to do an update query to one table (munparcel_zoning) with the sum of values from a column in another table (permability.permarea) where the type (permtype) is equal to a value (impervious). As this is a many-to-one, I am thinking I need a group by (parcelid). As there are two tables involved I am thinking the best way is to do an inner join, using parcelid = parcelid from each table. However, I am having issues with the query executing. Any help would be appreciated.

UPDATE munparcel_zoning
SET imperv = 
(SELECT Sum(permability.permarea)
    FROM permability
WHERE permability.permtype = 'impervious'
GROUP BY permability.parcelid)
INNER JOIN munparcel_zoning
ON permability.parcelid = munparcel_zoning.parcelid;

I am looking to do an update query to one table (munparcel_zoning) with the sum of values from a column in another table (permability.permarea) where the type (permtype) is equal to a value (impervious). As this is a many-to-one, I am thinking I need a group by (parcelid). As there are two tables involved I am thinking the best way is to do an inner join, using parcelid = parcelid from each table. However, I am having issues with the query executing. Any help would be appreciated.

UPDATE munparcel_zoning
SET imperv = 
(SELECT Sum(permability.permarea)
    FROM permability
WHERE permability.permtype = 'impervious'
GROUP BY permability.parcelid)
INNER JOIN munparcel_zoning
ON permability.parcelid = munparcel_zoning.parcelid;

I am looking to do an update query to one table (munparcel_zoning) with the sum of values from a column in another table (permability.permarea) where the type (permtype) is equal to a value (impervious). As this is a many-to-one, I am thinking I need a group by (parcelid). As there are two tables involved I am thinking the best way is to do an inner join, using parcelid = parcelid from each table. However, I am having issues with the query executing.

UPDATE munparcel_zoning
SET imperv = 
(SELECT Sum(permability.permarea)
    FROM permability
WHERE permability.permtype = 'impervious'
GROUP BY permability.parcelid)
INNER JOIN munparcel_zoning
ON permability.parcelid = munparcel_zoning.parcelid;
Source Link
Ryan Garnett
  • 9.5k
  • 8
  • 62
  • 108

Update query with sub query and join in Spatialite

I am looking to do an update query to one table (munparcel_zoning) with the sum of values from a column in another table (permability.permarea) where the type (permtype) is equal to a value (impervious). As this is a many-to-one, I am thinking I need a group by (parcelid). As there are two tables involved I am thinking the best way is to do an inner join, using parcelid = parcelid from each table. However, I am having issues with the query executing. Any help would be appreciated.

UPDATE munparcel_zoning
SET imperv = 
(SELECT Sum(permability.permarea)
    FROM permability
WHERE permability.permtype = 'impervious'
GROUP BY permability.parcelid)
INNER JOIN munparcel_zoning
ON permability.parcelid = munparcel_zoning.parcelid;