【发布时间】:2019-04-11 16:43:18
【问题描述】:
迄今为止,我只能运行涉及两个表的所有记录的 find_by_sql 查询来查找相交。
Regionpolygon.where('nation_id = ?', 74).find_by_sql "SELECT regionpolygons.id, area_name, destinations.id
FROM regionpolygons, destinations
WHERE ST_Intersects(regionpolygons.polygon_area, destinations.latlon)"
需要实现的两个目标是:
- 有一个较小的子集可以从中查询 regionpolygons
@rps = Regionpolygon.where('nation_id = ?',74).all这似乎可行.. - 从目标表
@dests = Destination.all @dests.each do |dest| [...]中提供一个点,以便迭代可以允许更新记录属性 添加到此类查询时,实例变量似乎没有被很好地消化
如何制定这个查询?
【问题讨论】:
标签: ruby-on-rails postgis