//构建消息表子查询
$sql = Db::table(DB_PREFIX.'message')
->field('a.id,c.title,c.create_time,c.type,a.tab,a.status')
->alias('a')
->where($my_where)
->join(DB_PREFIX.'message_text c', 'a.text_id = c.id','left')
->buildSql();
//构建sys表 union 联合
$data = Db::table(DB_PREFIX.'sys_message')
->alias('a')
->field('a.id,c.title,c.create_time,c.type,a.tab,a.status')
->join([[DB_PREFIX . 'message b', 'a.message_id = b.id','left'], [DB_PREFIX . 'message_text c', 'c.id = b.text_id','left']])
->union($sql,true)
->where($sys_where)
->buildSql();
//获得查询结果
$list = Db::table($data.' as a')
->order('a.create_time desc')
->paginate($page,false,['query'=>request()->param()]);
利用字查询 分页 field 字段必须一致