oracle中具有特殊化-泛化关系的连接表
我正在尝试对两个表进行联接。一种是超类型,一种是子类型。我还尝试将它与另一个表连接起来,这可行,但超类型和子类型的连接却不行。它说我的标识符无效,但两个 ID 都相同,所以我非常困惑为什么它不起作用。
我在下面添加了我的代码,附件显示了我的表格。我有一个表,我从中提取名字和姓氏,我的其他代码是从超类型和子类型表中提取。
SELECT first_name, last_name, gift_card_id, value_of_card
FROM gift_card
JOIN subject ON gift_card.subject_id = subject.subject_id
JOIN gift_card ON visa_gift_card.gift_card_id = gift_card.gift_card_id
GROUP BY gift_card.gift_Card_id
HAVING visa_gift_card.gift_card_id = gift_card.gift_card_id;
I am trying to do a join with two tables. One is a supertype and one is a subtype. I am also trying to join it with another table and that works but the joining of the supertype and subtype is not. It says I have invalid identifier but he same id is in both so I am extremely confused why it's not working.
I included my code below and the attachment shows my tables. I have a table I am pulling first name and last name from and my other code is pulling from the supertype and subtype table.
SELECT first_name, last_name, gift_card_id, value_of_card
FROM gift_card
JOIN subject ON gift_card.subject_id = subject.subject_id
JOIN gift_card ON visa_gift_card.gift_card_id = gift_card.gift_card_id
GROUP BY gift_card.gift_Card_id
HAVING visa_gift_card.gift_card_id = gift_card.gift_card_id;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是因为您的任何表中都没有
first_name
或last_name
。您还应该加入另一张桌子吗?另外,我不认为
group by
/having
是您想要的,因为您的选择列表中没有像sum
这样的聚合函数。This is probably because you don't have
first_name
orlast_name
in any of your tables. Is there another table you should be joining on?Also, I don't think
group by
/having
is what you want, since you have no aggregate functions likesum
in your select list.