帮助子查询!返回多于1行 [英] help with subquery! returns more than 1 row
本文介绍了帮助子查询!返回多于1行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不了解返回多行的问题:
i dont understand the problem with returning multiple rows:
这是我的桌子BBC:
name region area population gdp
Afghanistan South Asia 652225 26000000
Albania Europe 28728 3200000 6656000000
Algeria Middle East 2400000 32900000 75012000000
Andorra Europe 468 64000
Angola Africa 1250000 14500000 14935000000
etc.............................
问题:
列出国家名称和地区 在包含印度"的地区, 伊朗".
List the name and region of countries in the regions containing 'India', 'Iran'.
这是我的声明
select name from bbc where region = (select region from bbc where name='India' or name='Iran')
它返回:
sql: errorSubquery returns more than 1 row
我的陈述有什么问题?答案应为选择语句中选择语句的形式
whats wrong with my statement? the answer should be in the form of a select statement within a select statement
谢谢!
推荐答案
这是因为您试图将region
与值表进行比较.而是尝试使用in
:
This is because you are trying to compare region
to a table of values. Instead, try using in
:
select name
from bbc
where region in
(select region from bbc where name='India' or name='Iran')
这篇关于帮助子查询!返回多于1行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文