这是我目前的结果 mysql> select * from city;
bangaluru 91 bangaluru 6347673
bangaluru 91 bangaluru 347673
bangaluru 91 bangaluru 67673
andhra 91 andhra 63476
mangalore 91 mangalore 63473
这是我想要的:
bangaluru 91 bangaluru 6347673
91 bangaluru 347673
91 bangaluru 67673
andhra 91 andhra 63476
mangalore 91 mangalore 63473
答案 0 :(得分:1)
SELECT
CASE WHEN _no = @i THEN '' ELSE @i := _no END
as row_no,
_no,
_name
FROM
(
SELECT 1 as _no, 'vikas' as _name UNION ALL
SELECT 1, 'kratika' UNION ALL
SELECT 2, 'vikas'
) t,
(SELECT @i := '') temp