Zurab Kiknavelidze
07/29/2026, 6:08 AMRocky
07/29/2026, 6:08 AMSELECT ... INTO @variable syntax.
While StarRocks is compatible with the MySQL protocol, it does not support assigning query results directly to variables using the INTO clause. In StarRocks, the INTO keyword after a SELECT statement is specifically reserved for the SELECT ... INTO OUTFILE command (used to export data to files), which is why the error message suggests OUTFILE as the expected input.
Solution
To assign a query result to a user-defined variable in StarRocks, you must use the SET command with a subquery:
Incorrect (causes your error):
sql
SELECT column_name INTO @my_var FROM table_name LIMIT 1;
Correct:
sql
SET @my_var = (SELECT column_name FROM table_name LIMIT 1);
Other common causes for @ errors:
* Stage References: If you are coming from Snowflake, StarRocks does not use the @stage_name syntax. To query files directly, use the FILES() table function:
sql
SELECT * FROM FILES("path" = "<s3://bucket/file.parquet>", "format" = "parquet");
* Identifiers: If you have a column or table name that starts with @, you must enclose it in backticks:
sql
SELECT `@column_name` FROM table_name;
For more details on variable usage, you can refer to the StarRocks User-defined Variables documentation.
References
• sql-reference/sql-statements/loading_unloading/unloading/EXPORT.md
• sql-reference/sql-statements/loading_unloading/pipe/RETRY_FILE.md
• sql-reference/sql-statements/loading_unloading/SPARK_LOAD.md
• unloading/unload_using_insert_into_files.md
• sql-reference/sql-functions/table-functions/files.md