some
some在此表示满足其中一个的意义,是用or串起来的比较从句。
any
any也表示满足其中一个的意义,也是用or串起来的比较从句,与some的区别是any一般用在非“=”的比较关系中,这也很好理解,英文中的否定句中使用any肯定句中使用some,这一点是一样的。
any与max、min的对应关系
select *
from table1 t1
where t1.age > any( select t2.age
from table2 t2 )
--得到的结果是t1表中年龄大于t2表中任意一条数据的年龄即可,只要大于最小值就可以了
等效于
select *
from table1 t1
where t1.age > ( select min(t2.age)
from table2 t2 )
select *
from table1 t1
where t1.age < any( select t2.age
from table2 t2 )
--得到的结果是t1表中年龄小于t2表中任意一条数据的年龄即可,只要小于最大值就可以了
等效于
select *
from table1 t1
where t1.age < ( select max(t2.age)
from table2 t2 )