有2个table,
tableA{id:int,...} 和tableB{id:int,name:text tags:int[]}
怎么通过 tableB 的name找到相关的tableA中的id我的想法是这样的,
SELECT a.id
FROM tableA a, tableB b
where b.name ='a name'
and b.tags@> {a.id} ;//但是这里不知道该怎么写
//b.tags@>'{12334}'这样没错,但是'{a.id}'就不是integer了
在线等待...
tableA{id:int,...} 和tableB{id:int,name:text tags:int[]}
怎么通过 tableB 的name找到相关的tableA中的id我的想法是这样的,
SELECT a.id
FROM tableA a, tableB b
where b.name ='a name'
and b.tags@> {a.id} ;//但是这里不知道该怎么写
//b.tags@>'{12334}'这样没错,但是'{a.id}'就不是integer了
在线等待...
(
id integer NOT NULL,
lat integer NOT NULL,
lon integer NOT NULL,
tags text[],
CONSTRAINT planet_osm_nodes_pkey PRIMARY KEY (id)
)CREATE TABLE planet_osm_ways
(
id integer NOT NULL,
nodes integer[] NOT NULL,//包含planet_osm_nodes中id的array
tags text[],
pending boolean NOT NULL,
CONSTRAINT planet_osm_ways_pkey PRIMARY KEY (id)
)
连接起来
@> : contains ARRAY[1,4,3] @> ARRAY[3,1]
要求2边都是array而我的数据一边是array一边是integer
from planet_osm_nodes a , planet_osm_ways b
where a.id = ALL (b.nodes)