问题
I want to use a SQL Query with the WITH clause an I get a Syntax Error.
I´m using MySQL Version 5.6.28
Here a simple Code example
WITH alias_test AS (SELECT id, title FROM `tips_locations`)
SELECT id, title
FROM alias_test
Here the error I get in my SQL Tool
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 'alias_test AS (SELECT id, title FROM
tips_locations
) SELECT id, title FROM ali' at line 1
Can you Help me?
回答1:
MySQL doesn't support WITH
clause or CTE
and thus the error. Alternative, you can either use a temporary table or a normal table like
CREATE TEMPORARY TABLE alias_test AS
SELECT id, title FROM `tips_locations`;
SELECT id, title
FROM alias_test;
来源:https://stackoverflow.com/questions/42306058/sql-error-in-syntax-when-using-with