码迷,mamicode.com
首页 > 其他好文 > 详细

创建VIEW

时间:2015-06-28 12:27:30      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

1:创建view时如果两个表中有重名,那么可以给他们设置别名,如c.`name` advertiser_name.

SELECT c.`name` advertiser_name, c.`phone` advertiser_phone, c.`mail` advertiser_mail, c.`address` advertiser_address, p.`advertisementID`, p.`consumePerUserLimit`, p.`sharePerUserLimit`
FROM advertisement p, advertiser c
where c.`advertiserID` = p.`advertiserID`;

2:创建view是可以继续引用其他的view,如引用上边创建的view

SELECT a.`advertiser_name`, a.`advertiser_phone`, a.`advertiser_mail`, a.`advertiser_address`, a.`advertisementID`, a.`consumePerUserLimit`, a.`sharePerUserLimit`, g.`name`, g.`nickName`, g.`iconPath`, g.`imgPath`, g.`exchangeStepCounts`, g.`introduction`, g.`isRecommended` FROM advertisementAndAdvertiser a, gongZhongHaoInfo g
where a.`advertisementID` = g.`advertisementID`;

 

创建VIEW

标签:

原文地址:http://www.cnblogs.com/wlemory/p/4605321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!