This experiment employees database from https://launchpad.net/test-db/download
1.id column
If you want to concatenate multiple data tables in a SELECT statement, the execution plan is displayed based on the number of tables connected and gives the same ID. The following example has only one SELECT statement but joins multiple tables, at which point the ID value is not incremented and has the same ID:
Root@localhost: Mysql3316.sock One: -:Wuyi [Employees]>Explain extendedSelectE.emp_no,e.first_name,s.from_date,s.salary fromEmployees E,salaries SwhereE.emp_no=S.emp_no limitTen;+----+-------------+-------+------+----------------+---------+---------+--------------------+--------+-------- --+-------+|Id|Select_type| Table |Type|Possible_keys| Key |Key_len|Ref|Rows|Filtered|Extra|+----+-------------+-------+------+----------------+---------+---------+--------------------+--------+------- ---+-------+| 1 |Simple|E| All | PRIMARY | NULL | NULL | NULL | 299290 | 100.00 | NULL || 1 |Simple|S|Ref| PRIMARY, Emp_no| PRIMARY | 4 |Employees.e.emp_no| 4 | 100.00 | NULL |+----+-------------+-------+------+----------------+---------+---------+--------------------+--------+-------- --+-------+2Rowsinch Set,1Warning (0.00Sec
Instead, in the following query execution plan, the entire query statement consists of 3 SELECT statements, so the execution plan's records have different ID values:
Root@localhost: Mysql3316.sock A: A: * [Employees]>ExplainSelect( (Select Count(*) fromEmployees+(Select Count(*) fromDepartments)) asTotal_count;+----+-------------+-------------+-------+---------------+-----------+---------+------+--------+-------------- --+|Id|Select_type| Table |Type|Possible_keys| Key |Key_len|Ref|Rows|Extra|+----+-------------+-------------+-------+---------------+-----------+---------+------+--------+------------- ---+| 1 | PRIMARY | NULL | NULL | NULL | NULL | NULL | NULL | NULL |No tables used|| 3 |Subquery|Departments| Index | NULL |Dept_name| 122 | NULL | 9 |UsingIndex || 2 |Subquery|Employees| Index | NULL | PRIMARY | 4 | NULL | 299290 |UsingIndex |+----+-------------+-------------+-------+---------------+-----------+---------+------+--------+-------------- --+3Rowsinch Set(0.00Sec
MySQL Execution plan analysis