T-SQL Row_Number()Over()到MySQL

时间:2016-06-01 14:51:19

标签: mysql sql-server

我已经创建了一个T-SQL存储过程,我想将相同的过程写入MySQL。

DELIMITER ;;
CREATE procedure sproc_Test(in _comment text, in _type int, in _createddate datetime, in _fkkey int, in _userid int, in _rowno int)
begin
    set _comment=null;

    insert into tblTest1(comment,type,createddate,fkkey,userid)
    values(_comment,_type,_createddate,_fkkey,_userid);

    if(_type=1)then
        SELECT * FROM
        (SELECT ROW_NUMBER() OVER (ORDER BY tblTest1.id ASC) AS rownumber, tblTest1.*, tblTest2.name as username, tblTest3.name as location
        from tblTest1,tblTest2,tblTest3
        where tblTest1.userid=tblTest2.id and tblTest3.id=tblTest1.fkkey and tblTest1.type=@type) test1
        where test1.rownumber > _rowno and test1.rownumber <=_rowno+5;
    ELSE
        SELECT * FROM tblTest1;
    end if;
end

它在OVER关键字上给出了错误。

0 个答案:

没有答案