很多时候设计表时 并没有自增列, 当我们查询时希望 可以添加一列自增数字,可以利用自定义变量实现
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
结果中就体现出id一列
很多时候设计表时 并没有自增列, 当我们查询时希望 可以添加一列自增数字,可以利用自定义变量实现
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
结果中就体现出id一列