S
S
Sergey Semenko2014-11-19 13:54:05
MySQL
Sergey Semenko, 2014-11-19 13:54:05

Would such a request even work?

I understand almost nothing in MySQL, in short I made such a query, but I can’t check it yet, so I decided to ask you, how can I formulate the query in a different way, or is this also suitable?

SELECT
  LEAST(Ax, Bx) as minX, GREATEST(Ax, Bx) as maxX,
  LEAST(Ay, `By`) as minY, GREATEST(Ay, `By`) as maxY,
  LEAST(Az, Bz) as minZ, GREATEST(Az, Bz) as maxZ,
  @Ox := ' . $x1 .' as Ox, @Oy := ' . $y1 . ' as Oy, @Oz := ' . $z1 . ' as Oz
FROM `regions` WHERE Ox > minX AND Ox < maxX AND Oy > minY AND Oy < maxY AND Oz > minZ AND Oz < maxZ

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2014-11-19
@abler98

If I understand your task correctly, it should be like this:

SELECT * FROM `regions` WHERE
' . $x1 .' > LEAST(Ax, Bx) AND ' . $x1 .' < GREATEST(Ax, Bx) AND
' . $y1 . ' > LEAST(Ay, By) AND ' . $y1 . ' < GREATEST(Ay, By) AND
' . $z1 . ' > LEAST(Az, Bz) AND ' . $z1 . ' < GREATEST(Az, Bz)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question