mysql查询语句练习题
时间: 2023-10-14 18:31:48 浏览: 146
以下是一些MySQL查询语句练习题的例子:
1. 查询学生表中所有学生的姓名和年龄:
SELECT sname, sage FROM student;
2. 查询课程表中所有课程的名称和对应的教师姓名:
SELECT cname, tname FROM course
JOIN teacher ON course.tid = teacher.tid;
3. 查询成绩表中所有学生的姓名、课程名称和对应的成绩:
SELECT s.sname, c.cname, sc.score FROM student s
JOIN sc ON s.sid = sc.sid
JOIN course c ON sc.cid = c.cid;
4. 查询成绩表中成绩在80分以上的学生的姓名和课程名称:
SELECT s.sname, c.cname FROM student s
JOIN sc ON s.sid = sc.sid
JOIN course c ON sc.cid = c.cid
WHERE sc.score > 80;
5. 查询教师表中教师姓名以"李"开头的教师的编号和姓名:
SELECT tid, tname FROM teacher
WHERE tname LIKE '李%';
这些例子可以帮助你练习使用MySQL查询语句来检索和过滤数据库中的数据。你可以根据需要修改查询条件和字段选择来进一步练习。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [MySQL查询语句练习题45题版](https://blog.csdn.net/weixin_39718665/article/details/78161013)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [MySQL查询语句练习50题+答案](https://blog.csdn.net/qq_43278189/article/details/120110256)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文