You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select id, name
时间: 2023-07-24 07:14:12 浏览: 187
mysql报错:MySQL server version for the right syntax to use near type=InnoDB的解决方法
5星 · 资源好评率100%
The error message suggests that there is a syntax error in your SQL query near the line that starts with "select id, name". To diagnose and fix the issue, we need to see the complete query and the surrounding context.
However, based on the provided information, it seems that you might be trying to use the "WITH RECURSIVE" syntax in MySQL incorrectly. Here's an example of how you can use it correctly:
```
WITH RECURSIVE cte (id, name) AS (
SELECT id, name FROM your_table WHERE condition
UNION ALL
SELECT t.id, t.name FROM your_table t INNER JOIN cte ON t.parent_id = cte.id
)
SELECT id, name FROM cte;
```
In this example, "your_table" is the table you want to perform the recursive query on, "condition" is the condition that filters the initial rows, and "id" and "name" are the columns you want to select.
Make sure to replace "your_table" and "condition" with your actual table name and condition. Also, ensure that your MySQL server version supports the "WITH RECURSIVE" syntax.
If you provide more details about your query and the surrounding code, I can assist you further in identifying and resolving the syntax error.
阅读全文