Answer the question
In order to leave comments, you need to log in
How to write a query for a range of numbers?
Good afternoon. There are numbers in a column called priceFrom.
for example, priceFrom = 180,000.
I have an html form in which an amount is entered, for example, 150,000. And I want to get all records where priceFrom is less than 150,000 and more than 150,000 up to the sum of priceFrom, that is, up to 180,000.
I can’t understand , how to make a request to display this data?
Thanks for the help.
Answer the question
In order to leave comments, you need to log in
SELECT *
FROM `my_table`
WHERE `priceFrom` < 150000
OR (`priceFrom` > 150000 AND `priceFrom` <= 180000);
Everything is very bad ... Records less than 150000 and from 150000 to 180000 is one condition, less than 180000. Unless of course you wanted to ignore records = 150000.
Select * from table where priceFrom < 180000;
Select * from table where priceForm < 180000 and priceForm != 150000;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question