SELECT * FROM TABLE WHERE 1 = 2

database, mysql, sql

Solution

EXPLAIN is MySQL Utility Statement

The `EXPLAIN` statement can be used either as a way to obtain information about how MySQL executes a statement.

When you precede a `SELECT` statement with the keyword `EXPLAIN`, MySQL displays information from the optimizer about the query execution plan. That is, MySQL explains how it would process the statement, including information about how tables are joined and in which order.

In short, EXPLAIN statement is used to investigate how MySQL is executing the query.

Your statement generates following output -

id  select_type     table   type    possible_keys   key     key_len     ref     rows    Extra
1   SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE

As you can see under column `Extra` it is returning `Impossible WHERE` text. It means that MySQL has identified that it will result in zero rows.

Likewise other columns will help you to identify INDEXES being used and other useful information.

For more information please refer - EXPLAIN Syntax

Problem

The query: ``` Explain SELECT * FROM TABLE WHERE 1 = 2 ``` Displays the field names of the given table. Can anyone explain this syntax? Thanks in advance.

Original source