Which is the best (fastest) way to implement a list search in MySQL? My particular case is this:
- I have a list of rules (e.g. {1, 3, 11, 5, 6, 9, 1232, 4}). It could be implemented in PHP or MySql.
- I have a table in DB that lists applied rules (e.g. {1, 3, 6}) [table “applied”]
- I have to choose between the list of rules the first that has not be applied yet (in the example the result is 11 because 1 and 3 have been already applied).
- When a rule is choosen, it is executed (its associated action) and the “applied” table is updated (in the example the application inserts the 11 in the table : {1, 3, 6, 11})
Applied rules must be stored in database because only one rule is executed in each page load. Which is the best implementation for this kind of problems? Any sample code available?
To get the first rule which is not applied you can use
Then you perform the action associated with the rule, and insert a new record into
appliedtable.