I'm getting a syntax error on the following query:
SELECT 1,2 WHERE 1=1
But this query works fine:
SELECT 1,2 FROM (SELECT 1) t WHERE 1=1;
It almost looks like a WHERE clause always needs a table. Sometimes, in the depth of a complex query it's nice to use a SELECT/WHERE combo to turn on and off certain features. Is there a way to not always add the FROM (SELECT 1) t
?
Edit:
I found another similar issue
(SELECT 1 x)
UNION
(SELECT 2)
WHERE 1=1
gives a syntax error, but this does not:
SELECT x
FROM
(
(SELECT 1 x)
UNION
(SELECT 2)
) t
WHERE 1=1
I'm using 5.1.48-community MySQL Community Server (GPL)
. Is anyone else seeing this?