第24讲

来源:互联网 发布:旺角揸fit人 知乎 编辑:程序博客网 时间:2024/06/05 07:43
今日结果:
      1 一个 sqlite3_prepare(...)函数 使用完之后对应一个sqlite3_finalize(...)的释放资源函数; 一个sqlite3_get_table(...)使用后对应sqlite3_free_table(...)函数释放资源
      2  集合查询(并):(union) (union all) 查询时union的两边表的列数相同;
          select * from stu union  select * from stu_bak;    //    select * from stu union all select * from stu_bak;
      3  差集查询(A-B): (difference) select * from stu difference select * from stu_bak;
      4  in 中查询:(in)   select * from stu where classid in (select id from class) ;  //  not in | in
      5  exists查询:(存在) select a.* from stu a exists( select id from class b where a.classid = b.classid);  // not exists(不在此范围) 
          也可也关联查询: select a.* from stu a, class b where a.id = b.id;
      6  嵌套查询: select * from (select * from student  where ssex = '男' ) t1 where sage < 25; // t1 为虚拟表
      7  嵌套查询中使用聚合函数: select a.* from stu a (select max(id) maxid from stu ) b where a.id = b.maxid;
                                                                                                            最大id的别名   // 聚合函数有: sum( 字段)
                count( *),  avg( 字段), max( 字段), min( 字段), 
                select a.name as ‘姓名’ from student ; // ‘姓名’ 是a.name 的别名 
     8  group by 子句: select classid, count(*) from stu group by classid ; // 统计每个班级里的人数
                                    select classid , score, count(*) from stu group by classid , score; // 计算每个班级中每个分数的人数
                                    select classid , score , count(*) from stu group by class having count>2; // 计算每个班级中每个分数       的人数大于2 的人数                                                            只有 group by 出现时才用having
明日计划:首先,完成作业,对数据库的聚合函数,语句间的关系进行全面的复习,再做一些C++的题目进行复习。最后,再进行下一节课的预习。
感想: 慢慢的觉得自己以前上的知识是难么的重要,可是自己就没有好好的认真的学习,例如:操作系统,计算机网络,数据结构,SQLserver 等 现在想起来那些课程对电脑的应用性理解很是重要。如果有时间自己一定要对这些知识也要完整的进行学习。老师有说过: 学习是一种环的过程,不求甚解,从整体看局部,从局部看细节。但自己把某些事情干不好的时候,请对自己说,不是认真,与努力的错,而是要寻找对自己来说最好的方法,不断的尝试,知道做好。做事情时一定要记得:清楚自己的目标。加油!享受这个过程!
0 0
原创粉丝点击