说明
用于合并两个或多个 SELECT 语句的结果集
示例
Db::field(‘name‘) ->table(‘think_user_0‘) ->union(‘SELECT name FROM think_user_1‘) ->union(‘SELECT name FROM think_user_2‘) ->select();
Db::field(‘name‘) ->table(‘think_user_0‘) ->union(function($query){ $query->field(‘name‘)->table(‘think_user_1‘); }) ->union(function($query){ $query->field(‘name‘)->table(‘think_user_2‘); }) ->select();
Db::field(‘name‘) ->table(‘think_user_0‘) ->union([‘SELECT name FROM think_user_1‘,‘SELECT name FROM think_user_2‘]) ->select();
union all
Db::field(‘name‘) ->table(‘think_user_0‘) ->union(‘SELECT name FROM think_user_1‘,true) ->union(‘SELECT name FROM think_user_2‘,true) ->select();
Db::field(‘name‘) ->table(‘think_user_0‘) ->union([‘SELECT name FROM think_user_1‘,‘SELECT name FROM think_user_2‘],true) ->select();
时间: 2024-12-16 06:04:54