1.增加数据
insert into table_name ( column_name1, column_name2,...column_nameN ) values ( value1, value2,...valueN );
2.删除数据
delete from table_name [where conditions];
3.更新数据
update table_name set column_name=value [where conditions];
4.查询数据
select column_name from table_name [where conditions] [limit N][ offset M]; // limit 设定返回的记录条数 // offset 指定select语句开始查询的数据偏移量。默认情况下偏移量为0。
5.模糊查询
select * from position where name like 'java%';//%匹配任意长度字符,匹配中文用%% select * from position where name like 'java_';//_匹配任意单个字符 select * from position where name like 'java[?]';//匹配满足?条件的单个字符,[^?]匹配不满足条件的单个字符
6.交集查询
select column_name from tables [where conditions] union [all | distinct] //默认返回交集,不含重复数据,ALL返回所有交集数据 select column_name from tables [where conditions];
7.排序查询
select column_name from table_name order by field1 [asc [desc]]; //默认升序排列,desc为降序排列。
8.分组查询
select column_name from table_name [where conditions] group by column_name; //按colume_name进行分组,不含重复数据
9.连接查询
select * from table_name1 inner join table_name2 on conditions; // inner join(内连接,或等值连接):获取两个表中字段匹配关系的记录。 // left join(左连接):获取左表所有记录,即使右表没有对应匹配的记录。 // right join(右连接):用于获取右表所有记录,即使左表没有对应匹配的记录。
来源:https://www.cnblogs.com/weiyi2020/p/12420606.html