Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mySQL - Wrap Around Map

Status
Not open for further replies.

sgkdnay

Technical User
Aug 4, 2008
21
I have a grid that goes from 0,0 to 799,799 (800x800 blocks). The issue I'm having, I can't get my head working on this, an guidance or hint of help would be great. I can get the result as long it's inside the stated grid, but when it comes to wrap around the grid, it won't give me results.

ie (this will give me result with no problem):
Code:
SELECT * FROM map WHERE ((xaxis >= 0 AND xaxis <= 10) AND (yaxis >= 0 AND yaxis <= 10))

if i tried (wrap around grid), it will not give me any error or result:
Code:
SELECT * FROM map WHERE ((xaxis >= 795 AND xaxis <= 10) AND (yaxis >= 795 AND yaxis <= 10))

Then I got new help in trying using this code:
Code:
SELECT * FROM map
WHERE (((MOD(799,xaxis-1) >= 0) AND xaxis <= 10)
AND ((MOD(799,yaxis-1) >= 0) AND yaxis <= 10))
ORDER BY xaxis,yaxis

with this, it will only display starting from 0,0 and on. I'm trying to include, eg: 795,795 - 0,0. Any idea?

Thanks in advance!
 
First off, your second query below will not return any results cause xaxis cannot be both greater than 795 and less than 10. That logic will never return any records.
Code:
SELECT * FROM map WHERE ((xaxis >= 795 AND xaxis <= 10) AND (yaxis >= 795 AND yaxis <= 10))

Your third query using the MOD function is a bit confusing, if you could provide a little more information on the data and what you are trying to query, like examples, I can help.


Creator of - Game Reviews, Game Lists, and much more!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top