Click here to Skip to main content
16,005,206 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys this is my problem:
for example:

User inputed: 2000 as desired budget
User selected Wedding as desired service type


Here are the data in my database

ID Service type Price
1 Wedding 500
2 Wedding 700
3 Wedding 1000
4 Wedding 300
5 Wedding 1000

This is what will be the result
either

4 Wedding 300
2 Wedding 700
3 Wedding 1000

Or

3 Wedding 1000
5 Wedding 1000
Posted
Updated 4-Feb-15 5:25am
v2
Comments
CHill60 4-Feb-15 11:28am    
What have you tried?
Patrick sarmiento 4-Feb-15 19:52pm    
what? My Programming language here is php and my database here is mysql
CHill60 5-Feb-15 2:49am    
Whilst that information is useful we normally expect to see an example of code posted with a question like this, to demonstrate that you have actually tried something for yourself.
However Zoltán Zörgő has answered your question
Patrick sarmiento 5-Feb-15 7:18am    
ok ill post my code here

1 solution

What you intend to solve is called linear programming. A simple form of it, but still.
In general LP is not in the scope of any database engine. Solver can do this for you in Excel, but of course there are standalone programs and libraries you can use. Of course if you know the algoritm, you might be able to program it using one or the other RDBMS (check these considerations: https://www.simple-talk.com/sql/t-sql-programming/matrix-math-in-sql/[^]). Google for "simplex method" for the algoritm.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900