增删改查语法规范
増:
字符需要加 ' ' 引号。
insert into 表名 values ( 全部信息)。
insert into 表名(字符段1,字符段2,,,)values (值1,值2,,,,)。
删:
where
delete from 表名 where 字段=’xx‘
delete from 表名 where 字段=’xx' and 字段2=‘xx’;and并且
delete from 表名 where 字段=’xx‘ or 字段2=‘xx’; or 或者
= > < >= <= != <> 不等于
改:
update 表名 set 字段1='xx',字段2='xx' where 字段=‘xx’;
当字段=‘xx’ 改掉表中信息为 字段1=‘xx’,字段2=‘xx’
查:
select 字段1, 字段2, from 表名 where 字段=’xx‘ ; 当 字段=’xx‘ 查询 字段1, 字段2.
select 字段1,字段2 from 表名 ; 查询表格中所有的 字段1 ,字段2。
select * from 表名 ; 查询表中所有信息。
where 字段 between 1 and 20 ,1--20之间。
where 字段 in 或。
where 字段 is null 为空。
where stu_name like '%高%' 查找名字带有高字的。
max(求最大值) min(求最小值) count(查询结果) sum (求和)avg(求平均值) 它们只能跟在select后面。
select min(stu_age),from student_table查询表中年龄最小的
select count (*)from student_table 查询表中一共有多少行数据。
select count (stu_brith) from student_table 查询有多少人填写了生日。
select sum(stu_age) from student_table 求所有人的年龄之和。
select avg(stu_age) from student_table 求所有年龄的平均值。
模糊查询:
-
1. like (%表示任意多个字符,_表示单个字符)。
2. like'张_'可以查询姓张的两个字的名字。 ;stu_name like '张_'。
3. like'%张%' 可以查询名字里带张的人。 ;stu_name like '%张%'。
4. between and (判断是否在1--20之间)。 ;stu_age between 1 and 20。
5. in (在什么之间 代表或) 示例: stu_age(19,20,30)查询年龄为19,20,30的人。
6. null (表示没有信息) not(取反)。
7. is null 表示是 空 ; is not null 表示 不是空;
stu_birth is null 查询谁没有填写生日。 stu_birth is not null 查询谁填写了生日。
-