gpt4 book ai didi

mysql - 在 mysql 中使用简单的内部连接时遇到问题

转载 作者:太空宇宙 更新时间:2023-11-03 10:57:11 26 4
gpt4 key购买 nike

所以我基本上有一个看起来像这样的数据库:

card_types
id description price
1 Card1 1.00
2 Card2 2.00
3 Card3 3.00

card_occasions
id occasion
1 birthday
2 graduation
3 thank you
4 other

type_occasions
ID TypeID OccasionID
1 1 1
2 1 2
3 1 4
4 2 3

我正在尝试使用 WHERE card_type.ID = 1 进行内部联接,得到类似的输出,但我不知道从哪里开始。

示例输出:

card_occasion.ID   card_occasions.Name
1 birthday
2 graduation
4 other

如有任何帮助,我们将不胜感激。谢谢。

最佳答案

由于type_occasions已经拥有了typeid,所以不需要加入type表。

SELECT o.id, o.occassion
FROM card_occasions o
INNER JOIN type_occasions t ON t.occassionid = o.id
WHERE t.typeid = 1

关于mysql - 在 mysql 中使用简单的内部连接时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19375355/

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