各视图或函数中的列名必须唯一?????
create view select_news
as
select
AMUSEMENT.news_id,AMUSEMENT.news_title,AMUSEMENT.news_content,AMUSEMENT.news_time,AMUSEMENT.news_coming,AMUSEMENT.news_author,
FINANCE.news_id,FINANCE.news_title,FINANCE.news_content,FINANCE.news_time,FINANCE.news_coming,FINANCE.news_author,
GAME.news_id,GAME.news_title,GAME.news_content,GAME.news_time,GAME.news_coming,GAME.news_author,
HEALTHY.news_id,HEALTHY.news_title,HEALTHY.news_content,HEALTHY.news_time,HEALTHY.news_coming,HEALTHY.news_author,
MILITARY.news_id,MILITARY.news_title,MILITARY.news_content,MILITARY.news_time,MILITARY.news_coming,MILITARY.news_author,
SPORTS_NEWS.news_id,SPORTS_NEWS.news_title,SPORTS_NEWS.news_content,SPORTS_NEWS.news_time,SPORTS_NEWS.news_coming,SPORTS_NEWS.news_author
from AMUSEMENT,FINANCE,GAME,HEALTHY,MILITARY,SPORTS_NEWS
我的视图麻烦了点,不过问题出在哪啊?
总提示我:各视图或函数中的列名必须唯一。多次指定了列名 'news_id'(属于视图或函数 'select_newss')。
------解决方案--------------------
给他们取个别名例如
select
AMUSEMENT.news_id as a_news_id,MILITARY.news_id as m_news_di
------解决方案--------------------
楼上正解
视图也可以理解为表,其中的列名肯定不能重复
用别名as
------解决方案--------------------
SQL code
CREATE view select_news
AS
SELECT
a.news_id a_id,a.news_title a_title,a.news_content a_content,
a.news_time a_time,a.news_coming a_coming,a.news_author a_author,
f.news_id f_id,f.news_title f_title,f.news_content f_content,
f.news_time f_time,f.news_coming f_coming,f.news_author f_author,
#还有三个就省略了。。
FROM AMUSEMENT a,FINANCE,GAME f,HEALTHY h,MILITARY m,SPORTS_NEWS s
------解决方案--------------------
帮顶了