sql server 创建视图 可以添加一个字段标明该条数据来自哪个表嘛?怎么写?
1个回答
展开全部
给你举个例子,自己分析看下:
create view v_eventlist
as
select
ct.name as customertypename,
c.lastname,c.firstname,c.nickname,
emc.confirmdate,
e.code,e.datebegin,
t.name as tourname,
b.name as basecampname,e.comment
from tour as t
join event as e on e.tourid=t.tourid
join event_mm_customer as emc on emc.eventid=e.eventid
join customer as c on c.customerid=emc.customerid
join customertype as ct on ct.customertypeid=c.customertypeid
join basecamp as b on b.basecampid=t.basecampid
注意看,用FROM join进行多表关联引用。
追问
可以在视图中新建一个字段来标记该条数据是来自哪个表的嘛? 原表中没有可以区分表的字段。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询