It’s not a database operation, it’s a PHP operation.
For example:
$a="1,2,3,4,5,6,7,8,9,10,11"
$b=" 8,9,10,11,12,13,17,18,19,20"
$c="10,11,12,13,14,15,16,18,20,21, 22,23,24"
Required results
$a="1-11"
$b="8-13,17 -20"
$c="10-16,18,20-24"
Please give me guidance
Let’s be a bit stupid and split it first $strList = explode(",",$str);
After that, we can loop from the first or last one and compare 1 and -1.
When not equal, output the start bit and end bit, and then continue to the next step of the cycle.
You can also use recursion.