Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the relationship between the newly created table and the sorting out table in mysql

Shulou Source: shulou.com Published: 2022-05-31 15:56:22 10月02日 Update

This article is to share with you about the relationship between newly created tables and sorting out tables in mysql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

/ *

Navicat MySQL Data Transfer

Source Server: localhost

Source Server Version: 50520

Source Host: localhost:3306

Source Database: gupao

Target Server Type: MYSQL

Target Server Version: 50520

File Encoding: 65001

Date: 2018-07-24 22:42:54

, /

SET FOREIGN_KEY_CHECKS=0

-- Table structure for baoming

DROP TABLE IF EXISTS `baoming`

CREATE TABLE `baoming` (

`id`int (11) NOT NULL AUTO_INCREMENT

`sid` int (11) DEFAULT NULL

`kid` int (11) DEFAULT NULL

PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8

-- Records of baoming

INSERT INTO `baoming` VALUES ('1','1','1')

INSERT INTO `baoming` VALUES ('2pm,' 2pm,'1')

INSERT INTO `baoming` VALUES ('3','3','1')

INSERT INTO `baoming` VALUES ('44th,' 44th,'2')

INSERT INTO `baoming` VALUES ('54th,' 54th,'2')

INSERT INTO `baoming` VALUES ('6pm,' 6pm,'2')

INSERT INTO `baoming` VALUES ('74th,' 74th,'3')

INSERT INTO `baoming` VALUES ('9,'1,'3')

INSERT INTO `baoming` VALUES ('10','3','3')

INSERT INTO `baoming` VALUES ('11','5','3')

-- Table structure for class

DROP TABLE IF EXISTS `class`

CREATE TABLE `class` (

`cid` int (11) NOT NULL AUTO_INCREMENT

`level` int (11) DEFAULT NULL

`name` varchar (255) DEFAULT NULL

PRIMARY KEY (`cid`)

) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8

-- Records of class

INSERT INTO `class` VALUES ('1th,' 1th, 'Class 1')

INSERT INTO `class`VALUES ('2girls,' 1clients, 'class 2')

INSERT INTO `class` VALUES ('3','2', 'class 3')

INSERT INTO `class` VALUES ('4pm,' 3pm, 'class 4')

-- Table structure for ke

DROP TABLE IF EXISTS `ke`

CREATE TABLE `ke` (

`kid` int (11) NOT NULL AUTO_INCREMENT

`name` varchar (255) DEFAULT NULL

`tid` int (11) DEFAULT NULL

PRIMARY KEY (`kid`)

) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8

-- Records of ke

INSERT INTO `ke` VALUES ('1th,' course 1th,'2')

INSERT INTO `ke`VALUES ('2courses,' courses 2courses,'1')

INSERT INTO `ke` VALUES ('3 courses, 3 courses,'5')

INSERT INTO `ke` VALUES ('415,' course 415,'5')

INSERT INTO `ke` VALUES ('5miles,' course 0courses,'0')

INSERT INTO `ke` VALUES ('6 courses', null)

-- Table structure for student

DROP TABLE IF EXISTS `student`

CREATE TABLE `student` (

`sid` int (11) NOT NULL AUTO_INCREMENT

`name` varchar (255) DEFAULT NULL

`sex` int (11) DEFAULT'1'

`cid` int (11) DEFAULT NULL

PRIMARY KEY (`sid`)

) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8

-- Records of student

INSERT INTO `student` VALUES ('1students,' 1students, '1students,' 1')

INSERT INTO `student` VALUES ('2students,' students 2students, '1students,' 1')

INSERT INTO `student` VALUES ('3 students, 3 students, 2 students, 1')

INSERT INTO `student` VALUES ('4students, 4students,' 2students,'1')

INSERT INTO `student` VALUES (5 students, 5 students, 1 students, 2 students)

INSERT INTO `student` VALUES ('6students,' students 6students, '1students,' 2')

INSERT INTO `student` VALUES ('7students,' 7students, '2students,' 2')

INSERT INTO `student` VALUES ('8students, 8students,' 2students,'2')

INSERT INTO `student` VALUES ('9 students, 9 students, 1 students, 3')

INSERT INTO `student` VALUES ('10 years, 'student 0 years,' 1 students,'0')

-- Table structure for teacher

DROP TABLE IF EXISTS `teacher`

CREATE TABLE `teacher` (

`tid` int (11) NOT NULL AUTO_INCREMENT

`name` varchar (255) DEFAULT NULL

`sex` int (11) DEFAULT'1'

PRIMARY KEY (`tid`)

) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8

-- Records of teacher

INSERT INTO `teacher` VALUES ('1th,' Professor 1Qing,'1')

INSERT INTO `teacher` VALUES ('2', 'Professor 2','1')

INSERT INTO `teacher` VALUES ('3', 'Professor 3','2')

INSERT INTO `teacher` VALUES ('4pm,' Professor 4pm,'2')

INSERT INTO `teacher` VALUES ('5pm,' Professor','1')

INSERT INTO `teacher` VALUES ('6pm,' TA','2')

A teacher in class

SELECT DISTINCT t.name FROM ke

JOIN teacher AS t ON ke.tid=t.tid

The corresponding relationship between teachers and students

SELECT * FROM ke

JOIN teacher AS t ON ke.tid=t.tid

JOIN baoming AS b ON ke.kid=b.kid

JOIN student AS s ON b.sid=s.sid

Thank you for reading! This is the end of the article on "what is the relationship between the newly created table and sorting out the table in mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Students courses professors classes between Zhongxin contacts content more articles teachers good practical articles read knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information Docker Redmi OPPO Reno