I have a table
items
id int unsigned auto_increment primary key,
name varchar(255)
price DECIMAL(6,2)
I want to get at least 30 random ite
Depending on the average price and the price distribution you could try something like this:
Randomly select a few items less than you want in total (e.g. 25). Retry until their total amount is less than x.
Then use the concept linked in your question to find a combination that provides the remaining amount.