mysql query result add a column auto increment



 Many times there is no auto-increment column when designing a table. When we want to add a column of auto-increment numbers when we query, we can use custom variables to implement
SET @counter=0;
select @counter:=@counter+1 as id,
xytz_v2.COUNTRY .`code` as country_code,
xytz_v2.COUNTRY.CountryName_zh_CN as country_name,
'' as region
from xytz_v2.COUNTRY

The result shows the id column

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326607577&siteId=291194637