创建一个复杂的视图 [英] creating a complex view

查看:113
本文介绍了创建一个复杂的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想创建两个表的视图.
在两个表中都有一些未启用null的列.
我想插入两个表中的所有列.
如果表中的任何行都有,它也应该出现在视图中.

Hi All

I want to create a view of two tables.
In both tables there are some columns in which null is not enable.
I want to insert all the columns from both the tables.
If there are some rows in any of the table.It should also go in the view.
Is it possible?

推荐答案

你好,

您可以尝试

从表1中选择table1.*,table2.*左连接tbl1.key = tbl2.key上的table2
工会
从表2中选择table1.*,table2.*左连接tbl1.key = tbl2.key上的table1,其中tbl1.key为null

谢谢,我希望这会有所启发.

Aj
hello,

you could try something like

select table1.*, table2.* from table 1 left join table2 on tbl1.key=tbl2.key
union
select table1.*, table2.* from table 2 left join table1 on tbl1.key=tbl2.key where tbl1.key is null

Thanks and I hope this sheds some light.

Aj


这篇关于创建一个复杂的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆