0
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而不是選定區域內的成本。
現在我得到'#1054 - 未知列 'c.costs' 在「字段list'' – user2279927
@ user2279927你有一個名爲'costs'的列嗎? – Taryn
修正了它,現在我沒有得到正確的結果。獲得「空」而不是區域內的實際值。 – user2279927