Hader at sige dette, men MySQL
er den eneste RDBMS
af de fire store, der ikke har denne funktion.
I Oracle
:
SELECT *
FROM dual
CONNECT BY
level < n
I MS SQL
(op til 100
rækker):
WITH hier(row) AS
(
SELECT 1
UNION ALL
SELECT row + 1
FROM hier
WHERE row < n
)
SELECT *
FROM hier
eller ved at bruge tip op til 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
I PostgreSQL
:
SELECT *
FROM generate_series (1, n)
I MySQL
, intet.