Reputation: 39
With this query it show me all featured=1
records on first page and then on second they all disapear.
$sql = "(select * from `property` where (`city`='33') AND (`featured` = '1') LIMIT 5)
UNION ALL (select * from `property` where (`city`='33') AND (`featured` = '0') LIMIT 5) LIMIT 0,10 ";
I wanted to display 5 records of featured=1
and 5 records of featured=0
It is having the issue with the last Limit I think because when i remove the Limit at the end It show me all records of featured=1
on all pages but there occur a problem with the inner limits.
echo $sql = "(select * from `property` where (`city`='33') AND (`featured` = '1') LIMIT 5)
UNION ALL (select * from `property` where (`city`='33') AND (`featured` = '0') LIMIT 5) ";
Upvotes: 0
Views: 103
Reputation: 12847
If you want to get 5 records of featured = '1'
and union them with 5 records of featured = '0'
, following query do this :
(select * from `property` where (`city`='33') AND (`featured` = '1') LIMIT 5)
UNION ALL
(select * from `property` where (`city`='33') AND (`featured` = '0') LIMIT 5)
Upvotes: 1