Bug #87051 | Count query without key FROM keyword, executes successfully, returns 1 as count | ||
---|---|---|---|
Submitted: | 13 Jul 2017 7:26 | Modified: | 13 Jul 2017 8:00 |
Reporter: | Harsh Sharma | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.7.18 | OS: | Ubuntu |
Assigned to: | CPU Architecture: | Any | |
Tags: | count, SELECT |
[13 Jul 2017 7:26]
Harsh Sharma
[13 Jul 2017 8:00]
MySQL Verification Team
Hello Harsh, Thank you for the report. This is duplicate of Bug #37305, please see Bug #37305 Thanks, Umesh
[13 Jul 2017 9:22]
Roy Lyseng
MySQL allows the extension that if the FROM clause is omitted, the query behaves as if FROM DUAL is specified. DUAL is an embedded table with 1 row and no columns. Thus we allow this statement: SELECT 1 questions; as a synonym for SELECT 1 questions FROM DUAL; Likewise, any set functions like COUNT are also allowed: SELECT COUNT(*) questions; is equivalent to SELECT COUNT(*) questions FROM DUAL; However, SELECT * is not allowed because there are no tables to expand the column list from: SELECT *; and SELECT * FROM DUAL; are both invalid queries.