我的基本表里是又数据的但是创建的视图里面却没有,下面是代码:
--创建GoodsInfo,GoodsType,DiscountInfo,Brand视图
if exists (select * from sysobjects where name = 'vw_BGGD')
begin
drop view vw_BGGD;
end
go
create view vw_BGGD
as
select
B.brandName,
GI.goodsID, GI.brandID,GI.detailed,GI.goodsimage,GI.goodsName,GI.goodsNodes,
GI.goodsNums,GI.goodsPrice,
GT.typeID,GT.typeName,
DI.disDetailsID,DI.disID,DI.disIntro,DI.disTitle
from GoodsInfo as GI,GoodsType as GT,DiscountInfo as DI ,Brand as B
where B.brandID = GI.brandID and DI.disID = GI.disID and GT.typeID = GI.typeID;
go
--创建Display,GoodsInfo,GoodsType,DiscountInfo,Brand视图
if exists (select * from sysobjects where name = 'vw_DBGGD')
begin
drop view vw_DBGGD;
end
go
create view vw_DBGGD
as
select D.DisplayID,D.displaySize,D.goodsId,D.resolution,D.widescreen,
BGGD.brandID,BGGD.detailed,BGGD.disDetailsID,BGGD.disID,
BGGD.disIntro,BGGD.disTitle,BGGD.goodsimage,BGGD.goodsName,
BGGD.goodsNodes,BGGD.goodsNums,BGGD.goodsPrice,BGGD.typeID,
BGGD.typeName
from Display as D,vw_BGGD as BGGD
where D.goodsId = BGGD.goodsID;
go
--创建GoodsInfo,GoodsType,DiscountInfo,Brand视图
if exists (select * from sysobjects where name = 'vw_BGGD')
begin
drop view vw_BGGD;
end
go
create view vw_BGGD
as
select
B.brandName,
GI.goodsID, GI.brandID,GI.detailed,GI.goodsimage,GI.goodsName,GI.goodsNodes,
GI.goodsNums,GI.goodsPrice,
GT.typeID,GT.typeName,
DI.disDetailsID,DI.disID,DI.disIntro,DI.disTitle
from GoodsInfo as GI,GoodsType as GT,DiscountInfo as DI ,Brand as B
where B.brandID = GI.brandID and DI.disID = GI.disID and GT.typeID = GI.typeID;
go
--创建Display,GoodsInfo,GoodsType,DiscountInfo,Brand视图
if exists (select * from sysobjects where name = 'vw_DBGGD')
begin
drop view vw_DBGGD;
end
go
create view vw_DBGGD
as
select D.DisplayID,D.displaySize,D.goodsId,D.resolution,D.widescreen,
BGGD.brandID,BGGD.detailed,BGGD.disDetailsID,BGGD.disID,
BGGD.disIntro,BGGD.disTitle,BGGD.goodsimage,BGGD.goodsName,
BGGD.goodsNodes,BGGD.goodsNums,BGGD.goodsPrice,BGGD.typeID,
BGGD.typeName
from Display as D,vw_BGGD as BGGD
where D.goodsId = BGGD.goodsID;
go