an example to explain my problem:
user input is total amount, is for this example 26
I have a sql table like this:
product_id amount price
2 1 310,00
2 10 300,00
2 25 290,50
2 50 270,00
2 60 230,00
What I need is:
the price of the nearby amount of the total_amount.
So if the total_amount is 26 I need to get amount 25 from the table and with that value I need to get the price: 290,50
My own idea was to get first the amount values from the table that are equel or lower than teh total_amount:
SELECT aantal
FROM table
WHERE product_id = '2'
AND amount <= '$total_amount'
And then to get the highest value of the result with the php function max() and with that highest amount value a new query to get the price related to that highest amount value.
But there is also a MAX() function in SQL and I strongly believe there is a solution for one query to get this done. I already have tried some querys but it is not working.
BTW: I do visit this forum frequently but today I have registererd me, hello 🙂