Back to Clickhouse

loop

docs/en/sql-reference/table-functions/loop.md

26.4.1.1-new1.7 KB
Original Source

loop Table Function

Syntax {#syntax}

sql
SELECT ... FROM loop(database, table);
SELECT ... FROM loop(database.table);
SELECT ... FROM loop(table);
SELECT ... FROM loop(other_table_function(...));

Arguments {#arguments}

ArgumentDescription
databasedatabase name.
tabletable name.
other_table_function(...)other table function. Example: SELECT * FROM loop(numbers(10)); other_table_function(...) here is numbers(10).

Returned values {#returned_values}

Infinite loop to return query results.

Examples {#examples}

Selecting data from ClickHouse:

sql
SELECT * FROM loop(test_database, test_table);
SELECT * FROM loop(test_database.test_table);
SELECT * FROM loop(test_table);

Or using other table functions:

sql
SELECT * FROM loop(numbers(3)) LIMIT 7;
   ┌─number─┐
1.02.13.2 │
   └────────┘
   ┌─number─┐
4.05.16.2 │
   └────────┘
   ┌─number─┐
7.0 │
   └────────┘
sql
SELECT * FROM loop(mysql('localhost:3306', 'test', 'test', 'user', 'password'));
...