[eluser]ELRafael[/eluser]
Code:
SELECT
fields
FROM
TABLE st
INNER JOIN
OTHER_TABLE obs ON obs.REF = st.REF
WHERE
st.REF IN
(
SELECT
TOP %per_page% st2.REF
FROM
TABLE st2
WHERE
st2.REF NOT IN
(SELECT TOP %page_start% st3.REF FROM ST st3 ORDER BY st3.DESIGN)
ORDER BY
st2.DESIGN
)
%per_page% is how many registers you'll have in each page (like 10, 50, 100)
%page_start% is the start of pagination (1, 2, 3, 4).
Sure, in my query there is many others things, like WHERE field_name LIKE %something%. You'll need to make tests to see in which place of query you'll put the "wheres".
This case, I didn't use the CodeIgniter Database Library. Neither put this in Active Record. But You can try.