http://www.perlmonks.org?node_id=560175


in reply to Re^2: Getting combinations from a number's digits
in thread Getting combinations from a number's digits

If you have access to change the database, I wonder whether it would be better to store all the numbers sorted (either in the main table, or in a separate table), and then look them up that way. So if the user enters "312", you'd check for "123". Then you're only doing one lookup instead of 6.