1.查询:select * from 表名 where 查询条件; "like"为模糊查询匹配 between ... and ...: 查询一个区间范围的值; 闭区间
将查询出来的数据,进行排序;
关键字: order by 列名
排序方向: 升序 asc 默认是升序 ascending 升序的
降序 desc descending 降序的
---------------------语法
select 语句 order by 列名1 asc|desc,列名2 asc|desc,....;
子查询语句:
select * from 表名 where 列名 运算符 (子查询语句);
delete from 表名 where 列名 运算符 (子查询语句);
update 表名 set 列名 =值 where 列名 运算符 (子查询语句);
多表联合查询:
mysql的多表联合查询的语法。
SELECT 字段名 FROM 表1,表2 … WHERE 表1.字段 = 表2.字段 AND 其它查询条件
select * from 表名1,表名2,表3.... where 1个或者多个连接条件 [and 查询条件];
内连接,外连接
select * from 表名1 inner join 表2 on 表1表2的连接条件 inner join 表3 on 连接表3的条件 inner join
表4 on 连接表4的条件 .....;
内连接: inner join : 将满足连接条件的数据查询出来;
外链接:
左外连接:left outer join:将满足连接条件的数据查询出来;除此之外将左表中不满足连接条件的数据也查询出来
右外连接:right outer join:将满足连接条件的数据查询出来;除此之外将右表
分组查询:
select [分组的列名],分组函数 from 表名 group by 列名,... [having 分组函数 运算符 值];
插入:
insert into 表名(列名1,列名2,...) values(值1,值2,.....);
删除:
delete from 表名 where 1个或者多个查询条件;
修改:
update 表名 set 列名=值,列名1=值,.... [where 查询条件];
创建表:create table 表名(
列名 数据类型(size), ---列的定义
列名1 date,...........)
删除列: alter table 表名 drop( 列名, .........)
删除表:drop table 表名