sql 语句

--SELECT 列名称 FROM 表名称 WHERE 列 运算符 值
--select *from Student where sage<=19 and ssex!='M'
--select *from Student where sage<=19 or ssex!='M'
--SELECT * FROM Student WHERE (ssex='M' OR sage<20)AND sdept='CS'
--SELECT  FROM Orders ORDER BY Company
--select *from Student order by sage
--SELECT Company, OrderNumber FROM Orders ORDER BY Company, OrderNumber
--select *from Student order by sage,ssex  //正序排名
--select *from Student order by sage desc //逆序排名
--INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)
--insert into Student(sno,sname,sage,ssex,sdept) values(95005,'大猫',28,'M','AV')  插入
--Update 语句用于修改表中的数据。
--update Student set sname='小孩' where sage<=18 //更新一列
--UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'
--WHERE LastName = 'Wilson'
--update Student set sname='操蛋',ssex='F' where ssex='M'  

第二次上机

--select sname from Student,SC where Student.sno=SC.sno
--select *from Student,SC where Student.sno=SC.sno --查询两个表
--select sage from Student,SC where Student.sno=SC.sno  --把两个表中的sno相同的sage全都列出来
--select sname from Student
-- where sname not in (select sname  //not in 语句
--     from Student
--     where sname='李勇' or sname='刘晨')
--select sname from Student   //not in 语句的应用
-- where sname not in('李勇','刘晨','王敏','张立')
--select sname from Student where sname in('李勇','刘晨')
--select sname from Student where sname not in('李勇') and exists(select cname from Course where cname in('数学'))--exists 是判断是否存在,和in类似,但效率要比in高
--select  *from Student where not exists(select sname from Student where sname='大猫')
--SELECT DISTINCT JNO
-- FROM SPJ
-- WHERE PNO=’S1’
--select distinct sname from Student where sage='20'
--select *from Student
--insert into Student(sno,sname,sage,ssex,sdept)
 --values(95005,'张立',19,'M','WE')
--select sname from Student where sage=19
--SELECT PNAME, SUM(QTY)
-- FROM SPJ, J
-- WHERE SPJ.JNO=J.JNO
-- GROUP BY PNAME
--select ssex,sum(sage)  //对sage求和
  --  from Student 
   -- group by ssex    //以ssex为标准分组求和

原文地址:https://www.cnblogs.com/zhangdashuai/p/4063239.html