php - Can I Count How Many Results Come From Each MySQL Select / Union -
i have query follows format:
(select t.column1, t.column2 table t t.status = 1 limit 10) union (select t.column1, t.column2 table t t.status = 2 limit 10)
the end result need have 20 rows. if first select
statement can find 9 rows t.status = 1
, second select
statement use limit 11
instead of limit 10
i using php write , run query, looking execute within mysql can run 1 query.
any ideas appreciated.
add 1 more limit 'outside' total count , use same limit of 2-nd query.
( select t.column1, t.column2 table t t.status = 1 limit 10 # 1/2 of total rows ) union ( select t.column1, t.column2 table t t.status = 2 limit 20 # total rows ) limit 20 # total rows
Comments
Post a Comment