mysql三张表连接建立视图
三张表连接・・ A表的a字段 对应 B表的b字段 ,B表的b1字段对应C 表的c字段
现在 建立 一个视图,可以同时 看到三张表的 所有信息・~
create or replace view v_name as select t1.*,t2.*,t3.* from A表 t1, B表 t2, C表 t3 where t1.a=t2.b and t2.b1=t3.c
两表链接创建视图
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 ('1', 'zs', '18'); INSERT INTO `aa_user` VALUES ('2', 'ls', '20'); INSERT INTO `aa_user` VALUES ('3', '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 ('1', '1', '60'); INSERT INTO `tb` VALUES ('2', '1', '70'); INSERT INTO `tb` VALUES ('3', '2', '80'); INSERT INTO `tb` VALUES ('4', '2', '90');
创建视图
CREATE or REPLACE view aa_ta_view AS select a.*,b.fid,b.cc from aa_user a,tb b where a.id = b.fid;
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11