提问人:Ben Cassell 提问时间:9/12/2023 更新时间:9/12/2023 访问量:13
第二列:从上次插入的phpmyadmin自动递增
Second column Auto Increment from last inserted phpmyadmin
问:
我有一个生成的发票编号(当前 ID)表,其类型为 Primary Key AI。
我现在想将另一个/多个用户添加到表列表中,他们都从上一个发票号开始按顺序生成。主键现在将作为 ID AI 主键,但我想添加另一列,该列现在将是发票编号。
几天来,我一直在挠头,我能想到的唯一方法是检查电子邮件匹配的最后一个发票编号并将增量加 1,但这可行吗?最好的方法是什么?
| ID | Invoice Number | email |
| -------- | -------- | -------- |
| 1 | 120111 |[email protected] |
| 2 | 120111 |[email protected] |
| 3 | 120112 |[email protected] |
| 4 | 120112 |[email protected] |
| 6 | 120113 |[email protected] |
| 7 | 120114 |[email protected] |
| 8 | 120115 |[email protected] |
| 9 | 120116 |anothe[email protected] |
| 10 | 120113 |[email protected] |
我试过最后插入,但我唯一能做到这一点的方法是插入然后检查哪个是凌乱的。
答: 暂无答案
评论