select *from student
select student_id from student
select student_id ,student_name from student
select student_id student_name from student 将student_name 作为student_id的别名处理
如: select student_id a from student
select a=student_id from student
从student表中分别检索出学生的学号、姓名信息并分别加上“学生”、“学号”的标题信息。
select 学号=student_id,学生=student_name from student
大部分查询都不是针对表中所有行的查询,而是从整个表中选出符合条件的信息,要实现这样的查询就要用到
从student_course表中检索成绩小于60分的学生信息。
select grade from student_course where grade<60
select * from student_course order by student_id
select top 50 percent *from student_course order by student_id 输出总行数的一半
select top 10 *from student_course order by student_id 输出前10行
‘2007-11-18’ convert cast
date'2007-11-18'
student_course表中检索成绩介于60至80分之间的学生信息。
select student_id,grade from student_course where grade between 60 and 80
从student_course表中检索学号为‘g9940202’,‘g9940204’,‘g9940206’的学生信息。
select *from student_course where (student_id='g9940202')or(student_id='g9940204')or(student_id='g9940206')
select *from student_course
select distinct student_id from student_course
select *from student_course where (student_id='g9940202')or(student_id='g9940204')or(student_id='g9940206') order by student_id
从student表中分别检索出姓张的所有同学的资料;名字的第二个字是“红”或“虹”的所有同学的资料
select *from student
select *from student where student_name like '张%'and student_name like '%红'or student_name like '%虹'
select *from student where student_name like '_[红,虹]%'
SELECT * FROM student WHERE student_name LIKE '_[红,虹]%'
SELECT * FROM student WHERE student_name LIKE '_[^红,虹]%'
SELECT * FROM student WHERE student_name LIKE '李红b[大b]' ESCAPE 'b'
select *from student where home_addr is null
select top 10 * from student order by student_id
SELECT '学号'=student_id, '成绩'=grade from student_course order by student_id COMPUTE SUM(grade) by student_id
SELECT '学号'= student_id , '总成绩' = sum(grade) FROM student_course GROUP BY student_id order by '总成绩'
SELECT student_course.student_id , student_course.course_id , student_course.grade FROM student_course WHERE student_id IN ( SELECT student_id FROM student WHERE class_id = 'g99402' AND sex = 1 )
查询出“g99402”班所有男生的学号、课程号及相应的成绩。
select student_course.student_id , student_course.course_id , student_course.grade from student_course where student_id in (select student_id from student where class_id='g99402'and sex = 1 )
select *from mems
insert into mems values('sdaf','asdf','','fsdaf','adf','asdfsda','sdaf','fsdaf','sadf','sdafsdafsad','asdf','fsdaf')
update set
update mems set yaopinname='达到喀',yaopinfeilei='',rukushijian='',rukuliang='',jiliang='',jixing='',kucunliang='',jinjia='',yaozhunzi='',pihao='',youxiaoqi='',shengchanchangjia=''where yaozhunzi ='xzcv'
select *from mems where 2>1 and yaopinname like'123%'and youxiaoqi like'%'and shengchanchangjia like'%'rukushijian between 8 and 9
select *from mems where rukushijian between 1 and 100000