$ sql = sprintf(“SELECT * FROM stitch
);
这是我的阵列。
[stitch] => Array
(
[0] => Array
(
[id] => 7,
[name] => Sew buttonhole to front fly
)
[1] => Array
(
[id] => 8,
[name] => Sleeve hem
)
)
)
我需要这个结果
[stitch] => Array
(
[0] => Array
(
[id] => 7,
[name] => Sew buttonhole to front fly
[number_stitch] => 1
)
[1] => Array
(
[id] => 8,
[name] => Sleeve hem
[number_stitch] => 2
)
)
)
我怎么做[number_stitch]?
答案 0 :(得分:1)
尝试
select s.*, @rowcount:=@rowcount+1 ‘number_stitch’ from stitch s, (SELECT @rowcount:=0) r order by id;