sql基础
mysql 怎么在删除表记录的同时,清空表自增长字段的值。
例如:
table : book
id (自增长字段)
name
记录:
id name
1 one
2 two
sql: delete from book where id=1
执行sql后要达到得效果:
id name
1 two
请问在php中应该怎么实现呢?
------解决方案--------------------TRUNCATE TABLE book
------解决方案--------------------SQL code
select name,(select count(1) from book where id <= t.id) as id
from book t