自定义函数:获得整型包含行的数量的结果集

来源:互联网 发布:telnet 在端口23失败 编辑:程序博客网 时间:2024/06/06 12:51
drop table if exists t2;    create table t2    (      s1 int, primary key (s1)      )    engine=innodb;  delete from t2;insert into t2(s1) values(22),(54),(15),(69);select * from t2;drop function if exists vrno;delimiter // create function rno()  returns int  begin    set @rno = @rno + 1;    return @rno;  end;  //     delimiter ;set @rno=0;select rno(), s1 from t;/*+-------+------+| rno() | s1   |+-------+------+|     1 |    5 ||     2 |    4 ||     3 |    6 |+-------+------+*/
获得整型包含行的数量的结果集