[postgis-users] Update table based on identical rows but in one call

Nicolas Ribot nicolas.ribot at gmail.com
Fri Oct 7 04:52:18 PDT 2011


> Hi,
>
> I'm trying to update several rows of my table just with one call, based e.g., in the number of ID. For that I would like to do something like the following:
>
> UPDATE line SET survey = 'GT', type = 'MR', source = 'TY' WHERE id = '5' TO id = '15';
>
> I know this doesnt work, it's just to ask if there is a way of doing this in this way, just with one call.
>
> Thanks for any suggestions,
>

Hi,

The construct "WHERE id = '5' TO id = '15'" is meant to get a range of IDs?
If it is the case, then use the "between" operator

(Strangely, your ids seem to be strings. It won't be easy to order
them based on natural order. If ids are really numbers, you should
store them as numbers (faster to index, easier to work with))

UPDATE line SET survey = 'GT', type = 'MR', source = 'TY' WHERE
id::int between 5 and 15;

Though you should check the cast is ok in this case.

Nicolas



More information about the postgis-users mailing list