Are there any functions in MySQL like dense_rank() and row_number() like Oracle?

前端 未结 6 2012
别那么骄傲
别那么骄傲 2020-12-06 02:40

Are there any functions in MySQL like dense_rank() and row_number() like those provided by Oracle and other DBMS?

I want to generate an id

6条回答
  •  广开言路
    2020-12-06 03:31

    MySQL version 8 now has ROW_NUMBER. Documentation

    EXAMPLE:

    SELECT 
        ROW_NUMBER() OVER (ORDER BY s.Id) AS 'row_num', 
        s.product,
        s.title
    FROM supplies AS S
    

提交回复
热议问题