gpt4 book ai didi

Mysql 查询选项表

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

假设我有一张名为厨房的 table 。

我有第二个表,名为 kitchen_options。

它们通过 kitchen_id 链接。

厨房选项可能包括 fork 、盘子、炉灶。

fork 可能是 1,盘子可能是 2,等等...

因此选项表中的一些示例行可能如下所示:

1122 1
1122 2
1122 3
1123 1
1123 2
1124 3
1125 1

假设我想要所有有 fork 和盘子的厨房(1 和 2)。所以这应该返回 1122 和 1123,而不是 1125。

我该怎么做?

最佳答案

可能不是一个有效的解决方案,但您可以尝试:

select kitchen_id from kitchen_options
where kitchen_id in (select kitchen_id from kitchen_options where option = 1)
and kitchen_id in (select kitchen_id from kitchen_options where option = 2)

关于Mysql 查询选项表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34074595/

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