是否可以将ID保留最多几行。
让我必须使用3 API,om,vcomm,icube添加商店
现在,当我使用php随机添加三个商店时,它将作为第二个数据库进入
----------------------------
id | apiname |
-----------------------------
1-500 | icube |
501-1000 | om
1001 - 2000 | vcomm
-----------------------------------------
就像在上面的数据库中,当我单击icube api的商店时,它将被放置在1到500的ID中;当我单击om的商店时,它将被放置在500-1000的ID中;当我单击vcommm时,它将被放置在1001-2000,不能一一对应。
你能帮我么?
最佳答案
这应该工作
insert into tablename (id,apiname)
values ((select max(id)+1 from tablename t where t.apiname='icube'),'icube');
要么
insert into tablename (id,apiname)
values ((select max(id)+1 from tablename t where t.apiname='om'),'om');
关于php - 为php mysql中的特定行保留一些ID,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32859366/