Bug #94586 SELECT WHERE valid without FROM
Submitted: 7 Mar 2019 8:02 Modified: 7 Mar 2019 14:28
Reporter: James Smith Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.7.25 OS:MacOS (macOS 10.14.x Mojave x86_64)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[7 Mar 2019 8:02] James Smith
Description:
Supposed I have a table SomeTable with a single INT column.

This query works fine:

```
INSERT INTO SomeTable
SELECT 1 WHERE true
UNION
SELECT 2 FROM SomeTable WHERE true
```
https://i.imgur.com/uTr2ZR9.gif

But this gives a syntax error:

```
INSERT INTO SomeTable
(SELECT 1 WHERE true) 
UNION
(SELECT 2 WHERE true) 
```

> Error Code: 1064. 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 'WHERE true)' at line 4

How to repeat:
Create SomeTable with a single INT column and run the 2 queries above.

Suggested fix:
The above queries should either be both valid or both invalid.
[7 Mar 2019 14:28] MySQL Verification Team
Hi,

Thank you for your report. However, this is not a bug.

This is SQL not C or Java. 

Hence, you can not use:

WHERE true

as it makes no sense.

You can use :

WHERE 1=1

or with some BOOLEAN COLUMN:

WHERE Some_Boolean_Column IS TRUE.