Solved

how to change the query from oracle to  mysql.

Posted on 2016-10-05
3
72 Views
Last Modified: 2016-10-06
below query has been written in oracle.how to change this query in mysql.

select *
               from (
                    select rownum as rn, a.*
                    from (select * from test
                            where test_datetime  <= #{testDate}
                          order by test_datetime asc) a
                          )
              where rownum <= #{pageSize} and rn > #{offset}
0
Comment
Question by:chaitu chaitu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Expert Comment

by:ste5an
ID: 41829830
It's exactly the same in MySQL.

The interesting part is: In what front-end do you use? Cause the parameter format looks pretty suspicious.
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 41829842
java.
Is rownum  there in mysql?
0
 
LVL 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 41829858
Ah, I see. In this case you need an iterator:

SELECT T.*, 
       @rownum := @rownum + 1 AS rownum
  FROM yourTable T, 
       (SELECT @rownum := 0) R

Open in new window


E.g. untested
SELECT  * ,
		@rownum := @rownum + 1 AS rownumO
FROM    ( SELECT	@rownum := @rownum + 1 AS rownumI ,
                    A.*
          FROM      ( SELECT    *
                      FROM      test
                      WHERE     test_datetime <= '#{testDate}'
                      ORDER BY  test_datetime ASC
                    ) A,
					 (SELECT @rownum := 0) RI
        ) B ,
		(SELECT @rownum := 0) RO
WHERE   rownumI <= '#{pageSize}'
        AND rownumO > '#{offset} '

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question