oracle中具有特殊化-泛化关系的连接表

发布于 2025-01-12 01:08:56 字数 585 浏览 0 评论 0原文

我正在尝试对两个表进行联接。一种是超类型,一种是子类型。我还尝试将它与另一个表连接起来,这可行,但超类型和子类型的连接却不行。它说我的标识符无效,但两个 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.

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与往事干杯 2025-01-19 01:08:56

这可能是因为您的任何表中都没有 first_namelast_name。您还应该加入另一张桌子吗?

另外,我不认为 group by/having 是您想要的,因为您的选择列表中没有像 sum 这样的聚合函数。

This is probably because you don't have first_name or last_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 like sum in your select list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文