$data['list']=Db::field('name')
->table('table1')
->union(function($query){
$query->field('name')->table('table2');
})
->union(function($query){
$query->field('name')->table('table3');
//->page($p, $pagesize)///////会报错//////
->select();
报错:SQLSTATE[HY000]: General error: 1221 Incorrect usage of UNION and LIMIT
//////////////////////////////以下是解决办法////////////////////////////////////////
$list1 = Db::field('name')->table('table1')->where($where1)->buildSql();
$list2 = Db::field('name')->table('table2')->where($where2)->buildSql();
$list3 = Db::field('name')->table('table3')->where($where3)->union([$list1,$list2,$list3])->buildSql();
$data['list'] = Db::table( $list3.' a')
->field('name')
->page($p, $pagesize)
->select();
TP框架 中 union 无法分页 报错SQLSTATE[HY000]: General error: 1221 Incorrect usage of UNION and LIMIT
最新推荐文章于 2023-07-27 17:21:46 发布