mysql替换Oracle中的ROWNUM


select c.* from (
        select b.* from 
        (select @rownum :=@rownum + 1 AS rm,a.* from 
(SELECT @rownum := 0) r,

(


   ) a ) b where b.rm <= #{page}) c where c.rm >= #{page}


oracle:

SELECT *
FROM (SELECT M.*, ROWNUM RN
FROM (

select ques_name,ques_type,ques_options,ques_score,ques_serial,QUES_ID,QUES_ANSWER,QUES_EXPLAIN
from q_question_tab  
where ques_id in (SELECT ques_id FROM q_paper_question where paper_id=#{paperId})
and ques_type=#{ques.quesType} order by ques_serial 

) M
WHERE ROWNUM <= #{page}) z
WHERE RN >= #{page}

mysql:



select ques_name,ques_type,ques_options,ques_score,ques_serial,QUES_ID,QUES_ANSWER,QUES_EXPLAIN
from q_question_tab  
where ques_id in (SELECT ques_id FROM q_paper_question where paper_id=#{paperId})
and ques_type=#{ques.quesType} order by ques_serial 


你可能感兴趣的:(mysql替换Oracle中的ROWNUM)