sql语句 在表中插入一个新列 这段语句有问题?(报错:在关键字'add'附近有语法错误)
altertable(selecta.day,a.name,a.yuefenfrom(selectd1asday,name,yuefenfrompaibanunional...
alter table (select a.day,a.name,a.yuefen
from
(select d1 as day,name,yuefen
from paiban
union all
select d2,name,yuefen
from paiban
union all
select d3,name,yuefen
from paiban
union all
select d4,name,yuefen
from paiban
) a
where a.name='夏菲' and a.yuefen='9/1/2015')
add column (riqi) varchar(20) 展开
from
(select d1 as day,name,yuefen
from paiban
union all
select d2,name,yuefen
from paiban
union all
select d3,name,yuefen
from paiban
union all
select d4,name,yuefen
from paiban
) a
where a.name='夏菲' and a.yuefen='9/1/2015')
add column (riqi) varchar(20) 展开
1个回答
展开全部
alter table 不是这样用的啊,都不是一张实际存在的表,你alter操作没有任何意义
SELECT a.day,a.name,a.yuefen
INTO #temp
FROM (SELECT d1 AS day,name,yuefen
FROM paiban
UNION ALL
SELECT d2,name,yuefen
FROM paiban
UNION ALL
SELECT d3,name,yuefen
FROM paiban
UNION ALL
SELECT d4,name,yuefen
FROM paiban) a
WHERE a.name='夏菲' AND a.yuefen='9/1/2015'
ALTER TABLE #temp
ADD riqi DATETIME
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |