1.distinct 返回唯一的不同值select distinct no1,no2 from table1;
2.where 提取固定的条件
select * from table1 where id = 34; where 条件里的文本值要用单引号环绕 where 语句里的运算符: <> 不等于 between 在哪个范围内 like 搜索某种模式 in 指定针对某个列的多个可能值
3.关键字 order by/desc order by 关键字按照升序对记录进行排序 desc 关键字按照降序对记录进行排序
select * from website order by id; 升序
select * from website order by id,name; 多列升序
select * from website order by id desc: 降序
4.insert into 语句 向表格插入新的数据
4.1 只插入值 insert into table_name values(a1,a2,a3...);
4.2 指定列名和别插入的值 insert into table_name(c1,c2,c3...) values (a1,a2,a3...);
4.2.1 实例:insert into table_name(name,url,count) values('百度','https://www.baidu.com','4')
5.undate 更新表中存在的数据 更新websites 表中‘cainiao’的url 和count update websites set url = 'www.23.com',count = '6' where name = 'cainiao' !!! 如果没有where 字句,会更新整张表全部的url 和count
6.delete 删除表中的行 delete from websites where name = '百度' !!where 子句规定了哪些记录需要删除,如果省略,则所有的记录都会被删除 删除websites所有数据: delete from websites
7.limit 规定返回的记录数目 select * from websites limit 10;
8.like 用于where 子句中搜索列的指定模式
select * from websites where name like 'G%' 取name 以G开头的用户
select * from websites where name like '%k' 取name 以k 结尾的用户
select * from websites where name like '%mm%' 取name 包含mm 的用户
select * from websites where name not like '%mm%' 取name 不包含mm 的用户