In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
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!
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.