I have 2 mysql tables (same db), both containing content items. They share the exact same structure. The first contains items created after a certain date, the 2nd items before that date.
I need to combine the 2 tables within a query, one after the other, so when i loop through, i get all of the items.
The only thing is i need to know which row came from which table during the the loop…
$sql = "select * from items1 order by datecreated DESC LIMIT $start, $limit
UNION ALL
select * from items2 where website='abc.com' AND state=1 order by datecreated DESC LIMIT $start, $limit
";
That doesn’t work, but it also would cause problems anyway as how do i know what to set each $start point for each table (for pagination)?
ok no probs, just did it by creating a full php array and then looping through array and limiting that. Prob not very efficient, just got the job done!