In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how MySQL creates three relationship tables. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
1. Create a student table create table tbl_stu (id int not null primary key auto_increment,name varchar (45) not null) engine=innodb default charset=utf8
two。 Create the chart create table tbl_sub (id int not null primary key auto_increment,subject varchar (45) not null) engine=innodb default charset=utf8
3. Create a score table create table tbl_scores (id int not null primary key auto_increment,stu_id int,sub_id intscore decimal (5Power2), constraint sco_stu foreign key (stu_id) references tbl_stu (id), constraint sco_sub foreign key (sub_id) references tbl_sub (id))
4. Insert data insert into tbl_stu values (0, Xiao Wang); insert into tbl_stu values (0, Xiao Song); insert into tbl_stu values (0, Xiao Li); insert into tbl_sub values (0, "Chinese"); insert into tbl_sub values (0, "Mathematics"); insert into tbl_sub values (0, "English"); insert into tbl_scores values Insert into tbl_scores values, etc. Query all scores select s3.namejournal s2.scotjournal s1.score from tbl_scores as s1inner join tbl_sub as S2 on s1.sub_id = s2.idinner join tbl_stu as S3 on s1.sub_id = s3.id
6. Query the average score of the students select s3.namemagint avg (s1.score) from tbl_scores as s1inner join tbl_stu as S3 on s1.sub_id = s3.idgroup by s3.name
7. Total score ranking select s3.Name as s from tbl_scores as s1inner join tbl_stu as S3 on s1.stu_id = s3.idgroup by s3.name order by s desc
These are all the contents of the article "how to create three relationship tables by MySQL". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.