Mi dispiace dirlo, ma MySQL
è l'unico RDBMS
dei quattro grandi che non hanno questa caratteristica.
In Oracle
:
SELECT *
FROM dual
CONNECT BY
level < n
In MS SQL
(fino a 100
righe):
WITH hier(row) AS
(
SELECT 1
UNION ALL
SELECT row + 1
FROM hier
WHERE row < n
)
SELECT *
FROM hier
o utilizzando il suggerimento fino a 32768
WITH hier(row) AS
(
SELECT 1
UNION ALL
SELECT row + 1
FROM hier
WHERE row < 32768
)
SELECT *
FROM hier
OPTION (MAXRECURSION 32767) -- 32767 is the maximum value of the hint
In PostgreSQL
:
SELECT *
FROM generate_series (1, n)
In MySQL
, niente.