S
S
Sergey Semenko2014-11-19 01:44:07
PHP
Sergey Semenko, 2014-11-19 01:44:07

Can such a request be made?

Let's say there is a table regions: x | y | z it stores records like this: 12-20 | 0-30 | 14-25, that is, ranges of numbers, to make it clear, I write two points to the database: A (12; 0; 14) and B (20; 30; 25), this is my cube diagonal. And I need to check if point O(5; 5; 5) is in the given cube. I do not think that this can be done in a query, but at least tell me how best to implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philipp, 2014-11-19
@abler98

Based on the conditions of the problem, the structure of your database is incorrect.
Store data as:
Ax, Ay, Az, Bx, By, Bz.
And then the primitive

SELECT * FROM diagonal
WHERE Ox > Ax AND Ox < Bx AND Oy > Ay AND Oy < By AND Oz > Az AND Oz < Bz

This is if you know for sure that your first point has smaller coordinate values.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question