求视图语句
各位大虾:
小的编了一个办公应用程序。其中作到了视图,大致如下:
Create view sxxx
as
select table1.xx as name1,
table2.yy as name2,
table1.zz as name3
.....
现在因应用需要,在table2中建立了与table1.xx相同的字段来存储可能不同的信息
但这个视图怎么写呢。如果不把数据从table1.xx导入到table2.xx中的话。
就是说。当table2.xx中的值为null时,从table1.xx中取值。当table2.xx中的值不为空时,从table2.xx中取值。
等你们的好消息哦。
------解决方案--------------------Create view sxxx
as
select case when table1.xx is null then table2.xx else table1.xx end as xx,
table2.yy as name2,
table1.zz as name3
------解决方案--------------------Create view sxxx
as
select isnull(table1.xx,table2.xx) as name1,
table2.yy as name2,
table1.zz as name3
.....
from table1,table2
where 联接条件