在MYSQL中返回所有结果以及有限/偏移结果的最有效方法
下面的查询从我的表中获取所有有限的结果集。然而,我有一个表过滤器,它要求所有的结果都存在,以提供一个完整的选择范围。是否有一种方法可以组合查询,以便它获取所有结果以及有限/偏移结果在MYSQL中返回所有结果以及有限/偏移结果的最有效方法,mysql,sql,Mysql,Sql,下面的查询从我的表中获取所有有限的结果集。然而,我有一个表过滤器,它要求所有的结果都存在,以提供一个完整的选择范围。是否有一种方法可以组合查询,以便它获取所有结果以及有限/偏移结果 "SELECT phone_deal_phone_allocations.*, phone_deal_phone_allocations.id as allocation_id, phone_resell
"SELECT phone_deal_phone_allocations.*,
phone_deal_phone_allocations.id as allocation_id,
phone_reseller_monthly_deals.*,
phone_reseller_monthly_deals.id as deal_id,
phone_variations.*,
phone_variations.id as variation_id,
phone_colours.*,
phone_colours.id as colour_id,
phone_sizes.*,
phone_sizes.id as size_id,
phone_networks.*,
phone_networks.id as network_id
FROM
phone_deal_phone_allocations
JOIN phone_reseller_monthly_deals ON phone_reseller_monthly_deals.id=phone_deal_phone_allocations.deal_id
JOIN phone_variations ON phone_variations.id=phone_deal_phone_allocations.phone_variations_id
JOIN phone_colours ON phone_colours.id=phone_variations.phone_colour_id
JOIN phone_sizes ON phone_sizes.id=phone_variations.phone_size_id
JOIN phone_networks ON phone_networks.id=phone_reseller_monthly_deals.phone_networks_id
".$where."
AND phone_colours.phone_colour_name = 'Gold'
ORDER BY phone_sizes.phone_size_mb ASC
LIMIT 0, 4"
使用cte。全选union all select with limit。那么,您想要所有结果还是只想要一个子集?如果结果集sin
LIMIT
的总大小相当小,也许您可以缓存它,然后在UI上分页。使其易于帮助您:。