0

I want to update the sqlite table, the following is the example for updating one row:

update tpecroad set tnode = (SELECT  b.nodeid FROM "TPECRoad" as a
join tpecnode as b 
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry and a.pk =1)
where pk=1

but there are 168432 rows to be updated, is there any faster way to update the large amount of the data?

It's like changed a.pk=1~168432 and pk=1~168432

Thanks a lots!!

4

3 回答 3

0

如果我理解正确的问题,此查询可能会有所帮助:

update tpecroad a set tnode = (
    select b.nodeid from tpecnode b
    where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
)
where exists (
    select 1 from tpecnode b
    where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
);

编辑:如果 a.pk = b.pk 必须验证才能执行更新,查询将如下所示:

update tpecroad a set tnode = (
    select b.nodeid from tpecnode b
    where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
        and a.pk = b.pk
)
where exists (
    select 1 from tpecnode b
    where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
        and a.pk = b.pk
);
于 2015-02-17T19:37:22.187 回答
0

尝试这个:

Update tpecroad a
set tnode = (SELECT b.nodeid 
FROM tpecnode as b 
where pointn(tpecroad.geometry,numpoints(tpecroad.geometry)) = b.geometry)
于 2015-02-16T15:05:21.397 回答
0
update tpecroad as c
set tnode = ( SELECT  b.nodeid 
              FROM "TPECRoad" as a join tpecnode as b 
              where pointn(a.geometry,numpoints(a.geometry)) = b.geometry and a.pk = c.pk);
于 2015-02-16T09:47:45.943 回答