稍微挣扎一下,希望我能在这里得到一些答案。我试图从SQL命令中删除我的结果中出现的列。我不想要' player_id'要显示两次(第二次显示来自下面的连接语句)。尝试操作连接语句,但每次我都这样做,它无法获取数据。
select * from org_members
left join (select player_id, LISTAGG(ship_name, ', ') WITHIN GROUP
(order by ship_name) as Ships
from member_ships
group by player_id) ships
on org_members.player_id=ships.player_id
就像一个FYI,在oracle 11gXE上通过APEX运行。
答案 0 :(得分:1)
如果您不想要player_id
,那么最安全的事情就是列出您想要的列。
但是,如果您想使用*
:
select *
from org_members om left join
(select player_id,
LISTAGG(ship_name, ', ') WITHIN GROUP (order by ship_name) as Ships
from member_ships
group by player_id
) ships
using (player_id);
using
子句完全符合您的要求。
在你的情况下,我仍然会明确列出:
select om.*, ships.ships
from org_members om left join
(select player_id,
LISTAGG(ship_name, ', ') WITHIN GROUP (order by ship_name) as Ships
from member_ships
group by player_id
) ships
using (player_id);
答案 1 :(得分:0)
不确定,除非你显示当前的输出,但你应该说如下。除非您选择列,否则它不应出现两次。
select org_members.* from org_members
根据您的评论,在这种情况下,您应手动指定列名而不是使用*
select org_members.player_id,.....,ships.name,....