mysql union all limit的使用

To apply ORDER BY or LIMIT to an individual SELECT, place the clause inside the parentheses that enclose the SELECT,as follows

(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)
UNION
(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);

直接不带()会报语法错误。

猜你喜欢

转载自www.cnblogs.com/zhjh256/p/10919922.html