Update data requests can be used to update datasets within your Spotzi Mapbuilder Account. These requests can be used to update single records at a time or a dataset in its entirety. You can execute an update data request by adding an UPDATE request to the "q" parameter.
A typical update query is generally as follows:
The above statement is divided into:
The first section of the Update query:
Specifies which dataset needs to be updated with this update request.
All fields listed in the update list must be available within this dataset.
The second section of the Update query:
1. Specifies which updates are to be executed.
This part of the query begins with the word SET. This is followed by the name of the field that you're updating, as well as the value that the field needs to be updated to.
2. States which dataset is being requested.
The columns described in the first part of this query must exist within this dataset for your query to work.
The last — and optional — part of the update query:
Specifies which rows are included in the update. All rows meeting the requirements from the WHERE statement will be updated.
Below you will find some example queries that can be used with the Spotzi Webservice. The dataset names and fields used in these examples must be available in the requested webservice account in order to obtain a valid result.
The above statement updates the neighbourhood dataset; the field population will be set to 100 for all records.
The above statement also updates the neighbourhood dataset. The population of all records with neighbourhood_name "Centre" will be updated to 100. Records with a different neighbourhood_name will be ignored in the update.
The above statement updates the male_percentage column to a percentage of the male inhabitants, as well as updates the type to "rural". Only the records where neighbourhood_name is "Centre" will be updated.
For more information about SQL UPDATE statements, please consult the SQL section in our help center or see the official PostgreSQL tutorial.