如何在phpmyadmin中自动增加字符串

问题描述 投票:-1回答:1

如何将值列attachment_path自动增量为image1,image2 ....其中类型为VARCHAR可以使用php代码完成或直接在phpmyadmin中实现

enter image description here

php mysql
1个回答
0
投票

我从前面提到的duplicate编辑了适合你案例的答案。

你必须在表格中再添加2个字段。

  1. (例如:image_text)包含文字'Image'
  2. (例如:image_num)具有自动增量

image_text的默认值设置为“图像”。

autoincrement primary key设置image_num

ALTER TABLE tablename AUTO_INCREMENT=101;

不要忘记删除现有的attachment_path列。

UPDATE tablename SET attachment_path = concat( image_text, image_num ) ;
© www.soinside.com 2019 - 2024. All rights reserved.