一、SELECT
语句:
表:student
字段:S_id;S_name;S_birth;S_sex
表:score
字段:S_id;C_id;S_score
1、查询全体学生记录:
①、Select * from student;
②、select S_id,S_name,S_birth,S_sex from student;
2、按照某一个条件查询
#select field1,field2 from table where field > < = >= <=
①、select * from student where S_id = '02';
②、select * from student where S_birth <='1992.05.02'
3、按照多个条件查询
#select field1,field2 from table where field < > = <= >= and field < > = <= >=
select * from student where S_birth <= ' 1993.03.05' and s_sex ='女';
4、按照条件or查询(只要满足or左右的条件,即可查询到数据)
#select field1,field2 from table where field < > = <= >= or field < > = <= >=;
select * from student where S_birth <='1993.03.05' or S_sex = '女' or S_id = '01';
5、按照条件区间查询(between and)
#select field1,field2 from table where field (not)between value and value;
select * from student where S_birth between '1993.03.05' and '1995.06.12';
select * from student where S_birth not between '1993.03.05' and '1995.06.12';
6、在某个范围查询(in)
#select field1,field2 from table where field (not) in (value,value);
select * from student where S_birth in ('1993.03.06','1996.06.12');
select * from student where S_birth not in ('1993.03.06','1996.06.12');
7、模糊查询
#select field1,field2 from table where field (not) like 'value%'(%value%-只要带周,不管在哪个位置);
select * from student where S_name like '周%'
select * from student where S_name like '%周%'
8、统计查询(count)
#select count(field1) from table where
#select count(*)from table where
select count(*)from student where S_name like'周%';
9、统计查询(count)as
#select field1 as value from table where
select count(*) as 统计结果 from student where S_name like '周%';
10、多表查询
#select * from filed1,filed2 where filed1.某字段=filed2.某字段 (两表必须两个表都有共同字段)
select * from student,score where student.s_id=score.s_id
11、