﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Late Not Bad-文章分类-SQL</title><link>http://www.cppblog.com/lateCpp/category/16889.html</link><description>不带感情的学习技术</description><language>zh-cn</language><lastBuildDate>Mon, 16 May 2011 10:50:46 GMT</lastBuildDate><pubDate>Mon, 16 May 2011 10:50:46 GMT</pubDate><ttl>60</ttl><item><title>一个SQL实例</title><link>http://www.cppblog.com/lateCpp/articles/146430.html</link><dc:creator>lateCpp</dc:creator><author>lateCpp</author><pubDate>Sun, 15 May 2011 14:29:00 GMT</pubDate><guid>http://www.cppblog.com/lateCpp/articles/146430.html</guid><wfw:comment>http://www.cppblog.com/lateCpp/comments/146430.html</wfw:comment><comments>http://www.cppblog.com/lateCpp/articles/146430.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lateCpp/comments/commentRss/146430.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lateCpp/services/trackbacks/146430.html</trackback:ping><description><![CDATA[<p>题目：<br>以下是三张表明细：<br>学生（学号，姓名，性别）<br>课程（课程号，课程名，学分）<br>选课（学号，课程号，成绩）<br><br>要求查找：<strong>课程名为英语 男生/女生的平均分和最高分</strong><br><br>我在mysql中设计以下三个表模拟：<br><img height=158 alt="" src="http://www.cppblog.com/images/cppblog_com/latecpp/a.jpg" width=158 border=0>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img height=85 alt="" src="http://www.cppblog.com/images/cppblog_com/latecpp/b.jpg" width=188 border=0>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img height=182 alt="" src="http://www.cppblog.com/images/cppblog_com/latecpp/c.jpg" width=138 border=0><br><br><br><strong>分析</strong>：<br><br>要求从选课表中查找成绩，约束条件为：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.学生号由性别来决定<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.课程号由课程名决定<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.可以将约束1去掉，查找所有学号的成绩、最大成绩，然后用Group By语句来分类<br><br>因此，<strong>查询语句为</strong>：<br><img height=100 alt="" src="http://www.cppblog.com/images/cppblog_com/latecpp/SQL.jpg" width=279 border=0>（第一行末尾截图少截了一个右括号）<br><br><br><br><strong>结果</strong>：<br><img height=61 alt="" src="http://www.cppblog.com/images/cppblog_com/latecpp/RESULT.jpg" width=283 border=0><br><br><br>＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝<br><strong style="FONT-SIZE: 24pt">结论：<br><br>本质上属于简单的将多个表联合起来的SQL操作。<br><br><br></strong></p>
<img src ="http://www.cppblog.com/lateCpp/aggbug/146430.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lateCpp/" target="_blank">lateCpp</a> 2011-05-15 22:29 <a href="http://www.cppblog.com/lateCpp/articles/146430.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>