SQL || MySQL ||作者:穆尼塞卡·乌达瓦拉帕蒂

sql || mysql ||作者:穆尼塞卡·乌达瓦拉帕蒂

1.sql第2部分

1.创建类表

%ign%ignore_a_1%re_pre_1%

2.创建教师表

create table teacher (    teacher_id int primary key,    teacher_name varchar(100),    age int,    subject varchar(50),    experience int);

3.将教师数据插入表

insert into teacher(teacher_id,teacher_name,age,subject,experience)values(101, 'sk. sohana', 30, 'mathematics', 5),(102, 'u. munisekhar', 35, 'english', 8),(103, 'sk. nellu', 40, 'science', 10),(104, 'a. venu', 28, 'history', 3);

4.将类数据插入表

insert into class(class_id,class_name,teacher_id)(9, 'math', 101),(10, 'english', 102),(11, 'science', 103),(12, 'history', 104);

教师桌

teacher_id teacher_name age subject experience

101sk. sohana30mathematics5102u. munisekhar35english8103sk. nellu40science10104a. venu28history3105s. jagadeesh28telugu3

类表

class_id class_name teacher_id

9math10110english10211science10312history104从class表中获取数据

select * from class;
| class_id | class_name         | teacher_id ||----------|--------------------|------------|| 9        | math               | 101        || 10       | english            | 102        || 11       | science            | 103        || 12       | history            | 104        |

从教师表中获取数据 5年经验教师

select * from teacher whare experience >5
| teacher_id | teacher_name       | age | subject       | experience ||------------|--------------------|-----|---------------|------------|| 102        | u. munisekhar      | 35  | english       | 8          || 103        | sk. nellu          | 40  | science       | 10         |

7.查找munisekhar老师详细信息

select * from teacher where teacher_name='u. munisekhar'
| teacher_id | teacher_name       | age | subject       | experience ||------------|--------------------|-----|---------------|------------|| 102        | u. munisekhar      | 35  | english       | 8          |

8.找到 sk. sohana老师的经验?

Levity Levity

AI帮你自动化日常任务

Levity 206 查看详情 Levity

select experience from teacher where teacher_name='sk. sohana';
| experience ||------------||     8      |

9.查找老师的姓名和年龄,其中年龄为 29 至 39

select name,age from teacher where age between 29 and 39;
| teacher_name       | age ||--------------------|-----|| sk. sohana         | 30  | | u. munisekhar      | 35  | 

10.查找班级名称和老师姓名以使用左连接

select class.class_name, teacher.teacher_namefrom classright join teacher on class.teacher_id=teacher.teacher_id;
| class_name | teacher_name       ||------------|--------------------|| math       | sk. sohana         || english    | u. munisekhar      || science    | sk. nellu          || history    | a. venu            |

11.查找班级名称和所有教师姓名以使用右连接

select class.class_name, teacher.teacher_namefrom classright join teacher on class.teacher_id=teacher.teacher_id;
| class_name | teacher_name       ||------------|--------------------|| math       | sk. sohana         || english    | u. munisekhar      || science    | sk. nellu          || history    | a. venu            || null       | s. jagadeesh       |

12.查找班级名称和教师姓名以使用内连接

select class.class_name, teacher.teacher_namefrom classinner join teacher on class.teacher_id=teacher.teacher_id;
| class_name | teacher_name       ||------------|--------------------|| math       | sk. sohana         || english    | u. munisekhar      || science    | sk. nellu          || history    | a. venu            |

13.查找munisekhar班级显示他的姓名和班级

select teacher.teacher.name, class.class_namefrom teacher right join class on teacher.teacher_id=class.teacher_idwhere teacher.teacher_name = 'u. munisekhar';
| teacher_name       | class_name ||--------------------|------------|| U. Munisekhar      | English    |

以上就是SQL || MySQL ||作者:穆尼塞卡·乌达瓦拉帕蒂的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/741148.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
linux tomcat端口怎么设置
上一篇 2025年11月25日 15:29:28
AI语言生成视频全自动流程分享,从文案到剪辑一气呵成
下一篇 2025年11月25日 15:29:28

相关推荐

发表回复

登录后才能评论
关注微信