There is no function to get the row number in mysql, but we can get the row number by defining variables. Here is a simple example.
The data in the table is as follows:
Next, sort the price'price' and mark the row number, the sql is as follows:
SELECT
@rownum:= @rownum + 1 AS rownum,
trade_name,
price
FROM
(SELECT @rownum := 0) t,`t_commodity_information`
ORDER BY
price DESC;
The query result is as follows:
You can see that the row number has been marked for the data queried.