Get the App
SLTechnology News&Howtos  ›  Database  › 

Example Analysis of establishing View by joining three tables in mysql

Shulou Source: shulou.com Published: 2022-05-31 20:03:58 10月05日 Update

This article mainly shows you the "mysql three tables join to establish a view of the example analysis", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn the "mysql three tables join to establish a view of the sample analysis" of this article.

Three tables connect the a field of table A corresponds to the b field of B table, and the b1 field of B table corresponds to the c field of C table.

Now create a view, and you can see all the information of the three tables at the same time.

Create or replace view v_nameasselect t1.recording, recording t2.recording, recording from A Table T1, B Table T2, C Table t3where t1.a=t2.b and t2.b1=t3.c

Two tables are linked to create a view

CREATE TABLE `aa_ user` (`id` int (10) NOT NULL, `name` varchar (10) DEFAULT NULL, `age` int (10) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;INSERT INTO `aa_ user` VALUES ('1mm,' zs', '18'); INSERT INTO `aa_ user` VALUES (' 2mm, 'ls',' 20'); INSERT INTO `aa_ user` VALUES ('3mm,' ww', '19') CREATE TABLE `tb` (`id` int (10) NOT NULL, `fid` int (10) DEFAULT NULL, `cc` int (10) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;INSERT INTO `tb` VALUES ('1x,'1x, '60'); INSERT INTO `tb` VALUES (' 2th, '1th,' 70'); INSERT INTO `tb` VALUES ('3th,' 2th, '80'); INSERT INTO `tb` VALUES (' 44th, '2th,' 90')

Create a view

The above is all the contents of this article entitled "example Analysis of establishing View by joining three tables in mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Views fields examples analysis content articles learning help information at the same time easy to understand more organization knowledge editing industry watch chain information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn MySQL Microsoft Docker