- 删除id>10的记录:delete from user where id>10;
- 设置user表的自增字段起始值为10:alter table user anto_increment=10; 设置user表的自增字段起始值为10
- 表字段自我复制:insert into user select * from user;
*如果表有自增字段,自增字段是不能复制的,代码改为:insert into user(name,pass) select name,pass from user; - 更新表字段:update user set name='admin' where name is null;
- 添加表字段:alter table user add pid int(11);
- 删除表字段:alter table user drop pid;
- 显示表的列名信息:show columns from emp
- 把user表的password字段md5加密:update user set password=md5('password'); (*这只是更新之前的密码值,新插入的数据仍然是没有加密的,但是可以通过insert into user values(2,'admin',md5('admin'));来实现加密,那么每次插入自动加密应该怎么实现?)
- 同表中从一条记录更新另一条记录:update user set name=('select name from art where id=2') where id=1;
- concat函数(连接字符串): select concat(id,",",pid) from goods_type;