CREATE TABLE emp(id INT PRIMARY KEY,NAME VARCHAR(11),dep_id INT ,salary INT); CREATE TABLE dept(id INT PRIMARY KEY,NAME VARCHAR(11),parentid INT); 获取各部门人数信息: SELECT e.dep_id,d.name,COUNT(e.dep_id) FROM emp e,dept d WHERE e.dep_id=d.id GROUP BY e.dep_…
<pre name="code" class="html">mysql> explain select * from (select * from ( select * from test where id=1) a) b; +----+-------------+------------+------+---------------+------+---------+------+------+-------------+ | id | sele…