mardi 23 août 2022

Fetch the next strategy based on the old strategies in MySQL. Example 4,2,9,14 and find 11

I have the following doubt:

I have a table with 4 thousand records with the following columns, id, strategy, option and data.

The numbers are random, line by line.

I needed to check if the previous 3 records are part of my pattern and search for the next 2 numbers, line by line.

Example,

my previous strategies are for the search:

strategy: 4 strategy: 2 strategy: 9 current: 14

Now I need to look for the next strategy, which in this case would be 11, so I needed to consult the last 4 strategies and check if they match the ones I'm looking for.

I would need to fetch 4,2,9,14 and find 11, and it would have to be in ID order.

Below is an example print of my table.




Aucun commentaire:

Enregistrer un commentaire