0

It would have been ideal to do what I want to do in a MySQL query but I think I maybe quite limited after looking at BETWEEN.

So I've been looking at PHP...

So I have 2 numbers for a property size for example 200 - 3000

I then need to check if those 2 numbers and the range between them fall within another range, so in this example $sizemin = 500 and $sizemax = 1000

I've looked at the range() function but I can only seem to get it partially working.

7
  • What about 500 - 4000 ? Commented Nov 20, 2014 at 15:51
  • so you want a sql solution, a php solution or a mixture? bit unclear to me Commented Nov 20, 2014 at 15:52
  • are you just trying to check that the difference between two numbers is between sizeMin and sizeMax? Commented Nov 20, 2014 at 15:55
  • @MarkFisher The OP wants a MySQL solution. They're simply uncertain as to whether such a solution is available. Commented Nov 20, 2014 at 15:58
  • @Strawberry Thanks, though i'm not sure why there's a php element to this then. Seems like a curve ball, and OP hasn't clarified anywhere. Reads like "tried mysql - too hard, now moved to php to solve, here's some php variables and a function i may or may not have vaguely tried". also the title suggests either of the two, yet there isn't a question in the whole post. Commented Nov 20, 2014 at 16:36

1 Answer 1

1

Uhm... with BETWEEN in MySQL:

SELECT num1, num2 FROM table WHERE (num1 BETWEEN num3 AND num4) AND (num2 BETWEEN num3 AND num4);

If you get a result from the query, the numbers are inside the range...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.