MySQL:根据另一个表中的多个值从表中选择多个值(MySQL: Select multiple values from a table based on multiple values from a

编程入门 行业动态 更新时间:2024-10-28 07:26:57
MySQL:根据另一个表中的多个值从表中选择多个值(MySQL: Select multiple values from a table based on multiple values from another table)

我想返回所有关于这些区域的报告,这些报告属于宏观区域......

我想以某种方式

SELECT DISTINCT report FROM reports WHERE region = (SELECT distinct region from macroregions where macroregion = 'Africa')

宏观区域是撒哈拉,西非,热带非洲等地区

虽然这是不可能的,因为子查询会返回多个结果。

I would like to return all the reports that are about each of these regions, that belong to a macroregion...

I would like to somehow

SELECT DISTINCT report FROM reports WHERE region = (SELECT distinct region from macroregions where macroregion = 'Africa')

The regions in the macroregion are Sahara, West Africa, Tropical Africa,... etc

Although this is impossible since it the subquery would return multiple results.

最满意答案

SELECT DISTINCT report FROM reports WHERE region IN (SELECT distinct region from macroregions where macroregion = 'Africa')

也许你错过了IN运营商

SELECT DISTINCT report FROM reports WHERE region IN (SELECT distinct region from macroregions where macroregion = 'Africa')

Maybe you missed IN operator

更多推荐

本文发布于:2023-08-06 11:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448835.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   Select   MySQL   multiple   based

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!