Row combination choices based on condition - MySQL

Viewed 227

I have a working SQL query which returns the following results:

enter image description here

What I'm looking to be able to do is for MySQL to calculate the sum of the weight column and present combinations of rows from the above table in which the sum(Weight) <= 300. An example of the expected results using the table above would be:

enter image description here

My questions about this are: is this possible from with MySQL? Would I need to execute multiple SQL queries and how would I be able to produce the results illustrated above? Is it possible to achieve the first table and the combinations from one query?

1 Answers
Related