From: | Stuart <sfbarbee(at)gmail(dot)com> |
---|---|
To: | Lahari Sengupta <jhinik8(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Conditional update |
Date: | 2018-02-12 14:33:04 |
Message-ID: | CALmuyMopGff8HOim7hgijq9HqYBCJkvPh7Hyg9NNtJawG+oC=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Lahari,
I'm not sure about the st function but your query is slightly off, just
minor changes as below should work:
UPDATE sites st
SET time_stamp = *sv.*timing FROM servers sv
WHERE st_distance(st.geom, sv.geom) < 9 AND *sv*.workmode = TRUE ;
On Feb 12, 2018 3:33 PM, "Lahari Sengupta" <jhinik8(at)gmail(dot)com> wrote:
> I have two table name servers and sites. Servers contains timing and
> workmode and geometry values. Where sites contains geometry values and an
> empty time_stamp column. I want to fill this time_stamp column. For
> this, I want to check for all servers data whether it is within 9 unit
> distant from each sites. Hence, servers data 1 will search for all the
> sites and if it finds a site within 9 unit then it checks for its own work
> mode, if it is true then it writes the time in time_stamp column of that
> sites record. All the servers data with true work mode should find out one
> site. But there can be more sites. So, all the sites records might not
> update. For this I have written the following query. But not sure whether
> it is serving my purpose properly or not. Can anyone suggest?
>
> UPDATE sites st
> SET time_stamp = timing FROM servers sv
> WHERE st_distance(st.geom, sv.geom) < 9 AND st.workmode = TRUE
> ;
>
From | Date | Subject | |
---|---|---|---|
Next Message | ROS Didier | 2018-02-13 12:58:44 | pg_walldump and PITR. PostgreSQL 10.1 |
Previous Message | Lahari Sengupta | 2018-02-12 12:05:04 | Conditional update |