Query:
SELECT
tbl_a.id as aid,
tbl_a.name as aname,
null location,
.....
.....
from tbl_a
.........//left join to fetch some other data
.........//where condition
UNION ALL
0 aid,
null aname,
tbl_b.location as location,
.....
.....
from tbl_b
.........//left join to fetch some other data
.........//where condition
limit '.$recordperpage.' OFFSET '.$offset.'
此处,$recordperpage
和$offset
是动态的。
现在我想要取得所有不。没有限制的行。
EXA:
限制行数:20
没有限制的行数:50
我想要取消。没有限制的行(装置50)。
那么如何实现呢? 提前谢谢。
答案 0 :(得分:0)
也许SQL_CALC_FOUND_ROWS适合您? 看看这里。
How to count all records but only retrieve (LIMIT) a specific number for display?
答案 1 :(得分:0)
此查询可以解决问题:
SELECT count(*) as count
FROM
(SELECT
tbl_a.id as aid,
tbl_a.name as aname,
null location,
.....
.....
from tbl_a
.........//left join to fetch some other data
.........//where condition
UNION ALL
0 aid,
null aname,
tbl_b.location as location,
.....
.....
from tbl_b
.........//left join to fetch some other data
.........//where condition
) union_table