mysql insert generate serie 1

mysql insert generate serie

WITH RECURSIVE sequence AS (
    SELECT 1 AS level
    UNION ALL
    SELECT level + 1 AS value
    FROM sequence
    WHERE sequence.level < 10
)
SELECT level
FROM sequence;

Here is what the above code is Doing:
1. The WITH RECURSIVE clause is used to define a recursive common table expression.
2. The first SELECT statement defines the anchor member of the recursive sequence.
3. The second SELECT statement defines the recursive member of the recursive sequence.
4. The WHERE clause in the second SELECT statement specifies the termination condition for the recursion.
5. The final SELECT statement retrieves the data from the recursive sequence.

Similar Posts