thinkphp5 union 问题

浏览:3815 发布日期:2017/12/19 分类:ThinkPHP5专区
$list = Db::name('user_0')->union('SELECT * FROM rx_user_1')->union('SELECT * FROM rx_user_2')->limit(10)->select();

执行的sql 是 :
SELECT * FROM `rx_user_0` LIMIT 10 UNION SELECT * FROM rx_user_1 UNION SELECT * FROM rx_user_2

报错:
General error: 1221 Incorrect usage of UNION and LIMIT

把执行sql改为:
SELECT * FROM `rx_user_0` UNION SELECT * FROM rx_user_1 UNION SELECT * FROM rx_user_2 LIMIT 10
就正确了

最佳答案
评论( 相关
后面还有条评论,点击查看>>