Perhaps a matter of convenience
I once answered a post Table JOIN and CREATE new table extremely slow, mentioning how CREATE TABLE AS SELECT
will create a table and then perform INSERT INTO SELECT
to populate the table
There are ways to use LIMIT 0
to create a temp table without indexes
CREATE TABLE mytable SELECT * FROM othertable LIMIT 0;
In another post, MySQL Locks while CREATE TABLE AS SELECT, I mentioned under OPTION #2
using WHERE 1=2
as a way to create a blank temp table with no indexes
CREATE TABLE 1_temp_foo SELECT * FROM crm_companies WHERE 1=2;
ALTER TABLE 1_temp_foo ENGINE=InnoDB;
In terms of end result, using LIMIT 0
and WHERE 1=2
and even WHERE 0
are synonymous.
I agree with your assumption that it was allowed for no particular reason (because there's no real reason to not allow it, as you say), but it sure comes in handy for such occasions.
LIMIT
be a parameter (which could be 0) - or a subselect i.e.SELECT COUNT(foo) FROM bar
?`+1 for interesting question. – Vérace Mar 23 '16 at 16:15LIMIT 0
, but it might just be the case of "BecauseLIMIT 0
doesn't break anything" so no point making it illegal. – TMH Mar 23 '16 at 16:27WHERE 1=0
) will return column metadata. – a1ex07 Mar 23 '16 at 16:30