在MySQL中,有任何类似"level"的功能.在甲骨文 [英] In MySQL is there any function like "level" in Oracle

查看:1583
本文介绍了在MySQL中,有任何类似"level"的功能.在甲骨文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临一个场景,如果输入为10,我想要一个数字序列(1,2,3,... 10).

I'm facing a scenario, where if the input is 10, I want a sequence of numbers (1,2,3,...10).

在oracle中,level函数提供了该功能,我想知道如何在MySQL中执行相同的任务.

In oracle the level function provides that function, and I wish to know how to perform the same task in MySQL.

谢谢...

推荐答案

您可以在mysql中使用此查询

You can Use this query in mysql

SET @rownr=0;
SELECT @rownr:=@rownr+1 AS `rowNumber` FROM `tablename` limit 10

上面的查询生成该数字的序列,直到上限. 表名是您在db中的任何表

the above query generate sequence of that number upto the limit. Tablename is any of your table in db

这篇关于在MySQL中,有任何类似"level"的功能.在甲骨文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆