操作数据表中的记录

插入记录:

insert 表名 values();
自动编号的字段可以 赋值为nul 或 default

insert 表名 set 字段名 = “ ”;

将一个表的字段插入另一个表

insert 要插入的表(字段) select 插入的字段 from 原表 where 。。。。;

将users 插入 test 中
insert test (username) select username from users where age > 30;

单表更新:

update 表名 set 字段 = “ ”;
update 表名 set 字段 = “ ” , 字段= “ ”;

删除记录:

delete from 表 where 字段 = “”;

查询表达式:

select 字段1,字段2.,,,, from 表 ;

起别名:

select 字段1 as 别名, 字段2 as 别名 ..... from 表;

条件表达式:

where

查询结果分组:

select 字段 from 表 group by 字段;

对查询结果排序:

select * from 表 order by id desc ;

限制查询返回结果:

select * from 表 limit 2;

select * from 表 limit 2,3;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容