select sum(c.cost)
from (select x.num as x, y.num as y, max(priority) as maxpriority
from numbers x cross join
numbers y join
costs c
on x.num between c.x and c.x + c.deltax and y.num between c.y and c.y + c.deltay
where x.value between PIXELX and PIXELX and DELTAX and
y.value between PIXELY and PIXELY and DELTAY
group by x.num, y.num
) xyp join
costs c
on xyp.x between c.x and c.x + c.deltax and xyp.y between c.y + c.deltay and
xyp.maxpriority = c.priority
在寻找由区域填充的数据库中的两点之间的“成本”时,我得到了这个答案,每个区域都有不同的成本。我一直试图让它与找出数据库模式一起工作,目前我正在#1054 - Unknown column 'x.value' in 'where clause'
使用
Name Type Collation Attributes Null Default Extra Action
1 num int(11) No None Change Drop Browse distinct values More
作为数字和
# Name Type Collation Attributes Null Default Extra Action
1 x int(11) No None Change Drop Browse distinct values More
2 y int(11) No None Change Drop Browse distinct values More
3 deltax int(11) No None Change Drop Browse distinct values More
4 deltay int(11) No None Change Drop Browse distinct values More
5 priority int(11) No None Change Drop Browse distinct values More
作为成本。一直试图解决这个问题,非常感谢任何人的指点。
好的,它现在不会抛出错误,但它返回 null 而不是所选区域内的成本。