用一个例子讲:
数据库:world(MySQL自带),表city、country
查询与城市'Qandahar'、'Huambo'所在的国家代码相同或人口数比其多的城市信息
-- 方法1
select * from country
where continent = (select continent from country where name = 'Albania')
and region = (select region from country where name = 'Albania')
order by code;
-- 方法2
select * from country
where (continent, region) = (select continent, region from country where name = 'Albania')
order by code;
![](https://i-blog.csdnimg.cn/blog_migrate/ce704a94d755b9a3f7b998ee495a05ae.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cc981b4080b437bd92c5c2dcc68ba336.png)
方法二里面把where后的条件语句联合在一起,增加了代码的可读性。两段代码返回的结果一致。