Postgresql golang中的postgres查询

Postgresql golang中的postgres查询,postgresql,go,Postgresql,Go,我不知道如何在2dslice中进行postgres查询where(col1,col2) 我尝试了以下方法: CREATE TABLE table2 ( id CHAR(27) NOT NULL, lat FLOAT8 NOT NULL, lon FLOAT8 NOT NULL, PRIMARY KEY (id) ); latlongdata := [][]float64{} latlongdata = append(latlongdata, []float64{1.2, 2.

我不知道如何在2dslice中进行postgres查询where(col1,col2)

我尝试了以下方法:

CREATE TABLE table2 (
  id CHAR(27) NOT NULL,
  lat FLOAT8 NOT NULL,
  lon FLOAT8 NOT NULL,
  PRIMARY KEY (id)
);


latlongdata := [][]float64{}
latlongdata = append(latlongdata, []float64{1.2, 2.3},)
latlongdata = append(latlongdata, []float64{1.3, 2.4},)
......................................
latlongdata = append(latlongdata, []float64{1.4, 2.5},)

fmt.Println(latlongdata)// prints [[1.2 2.3] [1.3 2.4] ....... [1.4 2.5]] (very long array)

Query: r.db.QueryContext(ctx,("SELECT id, lat, lon FROM table2 WHERE (lat, lon) IN $1", latlongdata,)

你能建议怎么做吗?

在切片上搜索并进行查询

对于uz,数据:=范围latlongdata{
lat:=数据[0]
long:=数据[1]
err:=r.db.QueryContext(ctx,(“从表2中选择id、lat、lon,其中lat=$1和lon=$2”,lat、lon,)。扫描(&variable)
如果错误!=零{
log.Fatal(“无法执行搜索查询”,错误)
}
//还要检查“变量”的所有字段是否都不为空
//然后将结果附加到变量数组中
变量=追加(变量,变量)
}

我自己解决了。我的查询实际上有效。证据: