mysql查询出现 Incorrect usage of UNION and LIMIT错误
mysql查询出现 Incorrect usage of UNION and LIMIT错误
mysql> explain select * from user limit 10 union select * from user limit 10,10; 1221 - Incorrect usage of UNION and LIMIT
原来是由于少了 (),改为如下就行了:
mysql> explain (select * from user limit 10) union (select * from user limit 10,10); +------+--------------+------------+------------+------+---------------+------+---------+------+---------+----------+-----------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+--------------+------------+------------+------+---------------+------+---------+------+---------+----------+-----------------+ | 1 | PRIMARY | user | NULL | ALL | NULL | NULL | NULL | NULL | 6556851 | 100 | NULL | | 2 | UNION | user | NULL | ALL | NULL | NULL | NULL | NULL | 6556851 | 100 | NULL | | NULL | UNION RESULT | <union1,2> | NULL | ALL | NULL | NULL | NULL | NULL | NULL | NULL | Using temporary | +------+--------------+------------+------------+------+---------------+------+---------+------+---------+----------+-----------------+ 3 rows in set