How does mysql query two tables?
Mysql two-table query method: 1. Use “select field list from table 1, table 2 [where condition]” to query; 2. Use “SELECT field list FROM table 1 keyword JOIN table 2 ON Table1.Field = Table2.Field;” to query. How does mysql query two tables? The following article will introduce to you the method of multi-table query in mysql. There is a certain reference value, and friends in need can refer to it, and I hope it will be helpful to everyone. Multi-table joint query #Create table and data # create department CREATE TABLE IF NOT EXISTS dept ( did int not null auto_increment PRIMARY KEY, dname VARCHAR(50) not null COMMENT ‘Department Name’ )ENGINE=INNODB DEFAULT charset utf8; #Add department data INSERT INTO `dept` VALUES ('1', 'teaching department'); INSERT INTO `dept` VALUES ('2', 'Sales Department'); INSERT INTO `dept` VALUES ('3', 'Marketing Department'); INSERT INTO `dept` VALUES ('4', 'Personnel Department'); INSERT INTO `dept` VALUES ('5', 'Dept of Encouragement'); — Creator DROP TABLE IF EXISTS `person`; CREATE TABLE `person` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `age` tinyint(4) DEFAULT '0', `sex` enum('Male','Female','Shemale') NOT NULL DEFAULT 'Shemale', `salary` decimal(10,2) NOT NULL DEFAULT '250.00', `hire_date` date NOT NULL, `dept_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`)…