gpt4 book ai didi

mysql - 代码 - 1248 - 每个派生表都必须有自己的别名?

转载 作者:行者123 更新时间:2023-11-29 23:56:26 25 4
gpt4 key购买 nike

我正在尝试使用联合创建新表,这些代码有什么问题?

insert into chart

select months, field, value from (

select hp.months, 'ActualBookings2014' as field, hp.ActualBookings2014 as value
FROM hp_metglobal.hp

UNION

select hp.months, 'TargetBookings' as field, hp.TargetBookings as value
FROM hp_metglobal.hp

UNION

select hp.months, 'ActualBookings2013' as field, hp.ActualBookings2013 as value
FROM hp_metglobal.hp

)

最佳答案

请为内表使用别名:

insert into chart

select months, field, value from ((

select hp.months,
'ActualBookings2014' as field,
hp.ActualBookings2014 as value
FROM hp_metglobal.hp

UNION

select hp.months,
'TargetBookings' as field,
hp.TargetBookings as value
FROM hp_metglobal.hp

UNION

select hp.months,
'ActualBookings2013' as field,
hp.ActualBookings2013 as value
FROM hp_metglobal.hp

) as t)

关于mysql - 代码 - 1248 - 每个派生表都必须有自己的别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25302449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com