<@U0A71G31CDV> I have error Getting syntax error a...
# questions-and-troubleshooting
z
@Rocky I have error Getting syntax error at line 1, column 21. Detail message: Unexpected input '@', the most similar input is {'OUTFILE'}.
r
This syntax error typically occurs when you try to use the MySQL-style
SELECT ... 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):
Copy code
sql
SELECT column_name INTO @my_var FROM table_name LIMIT 1;
Correct:
Copy code
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:
Copy code
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:
Copy code
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