如何在mysql表中获取以下输出?
来源表:
id values
1 a
2 b
3 c
4 d
5 e
结果:
id values
1 a
2 ab
3 abc
4 abcd
5 abcde
答案 0 :(得分:1)
SELECT a.id, (@inc := concat(@inc, a.name)) AS Name
FROM mytable a, (SELECT @inc:= '') c ORDER BY a.id ASC