1. 程式人生 > >分表查詢,分表查詢count記錄總數

分表查詢,分表查詢count記錄總數

分表查詢

(select {$fields} from {$table} where {$where}) union all (select {$fields} from {$table} where {$where}) order by {$orderBy} limit {$limit}

分表查詢記錄總數,count(),sum()

select sum(count) as num from (select count(*) as count from {$table} where {$where} union all select count(*) as count from {$table} where {$where}) as total