mysql - Nearest free coordinates in database -
i have x , z coordinates in database. coordinates integers.
each coordinate bigger or equal 0.
i need nearest free (not in database) coordinates 0;0 don't want limit 1 coordinate specified number.
again, don't want nearest coordinate in database, want nearest free coordinate.
this did myself. tells me free space in coordinates square (limited maximum x , maximum z coordinates in database).
problem cannot select free coordinates that. distance free coordinates not coordinates.
select distance ( select (x+z) distance,count(owner) count coordinates group x+z asc ) coor coor.distance != coor.count-1
i'd try that:
select x, z ( select x, z+1 z coordinates union select x+1, z coordinates union select x+1, z+1 coordinates union select 0, 0 ) q concat(x,'_',z) not in (select concat(x,'_',z) coordinates) order (x+z) asc limit 1
Comments
Post a Comment