I'm trying to page through this table so I ended up with this query (which is not working).
SELECT MIN(user_uid) AS FIRST,
MAX(user_uid) AS LAST,
user_number, user_name
FROM user_table
WHERE user_uid > MAX(FIRST,{0}) AND user_uid < MIN(LAST,{1})
AND ( user_name LIKE '%{2}%' OR user_number LIKE '%{3}%' )
AND user_category={4} OR user_category={5}
ORDER BY user_uid LIMIT {6}
I'm getting parameters' values from my c# variables. I'm storing FIRST, LAST externally to use them for moving to next/previous pages.
I created this index too:
CREATE INDEX idx1 ON user_table (user_uid);
please note: I saw this answer, but this is the only way I thought about to get First and Last values.
How to page in this table efficiently?