最智能的方法来进行冗余SQL查询

时间:2014-05-08 13:05:20

标签: sql postgresql postgis

我需要像这样建立查询链:

CREATE TEMPORARY TABLE p_101_108 AS SELECT ST_difference(a.geom,(SELECT st_union(b.geom)  FROM rt_108 as b)) as geom FROM p_101_u as a;
CREATE TEMPORARY TABLE p_101_129 AS SELECT ST_difference(a.geom,(SELECT st_union(b.geom)  FROM rt_129 as b)) as geom FROM p_101_108 as a;
CREATE TEMPORARY TABLE p_101_201 AS SELECT ST_difference(a.geom,(SELECT st_union(b.geom)  FROM rt_201 as b)) as geom FROM p_101_129 as a;

更准确地说,第一个结果转到第二个查询,依此类推......
还有其他最聪明的方法吗? 我试着用我需要的所有表的名字创建一个新表,但我不知道如何结束它......

CREATE TABLE "HIDE_101" (hider varchar(6));
    INSERT INTO "HIDE_101" (hider) VALUES ('rt_108'),('rt_129'),('rt_201'),('rt_207'),('rt_208'),('rt_501'),('rt_502');

任何人都可以建议我,谢谢你

Cursore

0 个答案:

没有答案