2016-03-01 211 views
-16

得我在我的表查询相同的错误:SQL查询返回错误结果

  1. 国家
  2. CountryLanguage

如果我把任何或所有关键字子查询之前运行,但预计不会结果如何?

select countrycode,language 
from countrylanguage 
where countrycode = 
(select countrycode from country where region like '%Asia%'); 
+5

添加问题的有效标题。 –

+1

“abcdefghijklmnopqrstuvwxyz” 哈哈,认真吗? – Chendur

+4

我不知道你在问什么。 –

回答

0

由于子选择可能返回多行,做IN而不是=

select countrycode, language 
from countrylanguage 
where countrycode IN (select countrycode from country where region like '%Asia%'); 

或者,也许甚至更好,做一个JOIN来代替。

select countrycode, language 
from countrylanguage cl 
join country c ON cl.countrycode = c.countrycode 
where c.region like '%Asia%'