热线电话:13121318867

登录
2018-11-27 阅读量: 865
子查询

子查询:写在()中,把内层查询结果当做外层查询参照的数据表来用

例: 用in操作符与子查询语句来查询所有f_id对应的f_price在10元到20元之间的水果记录

select * from fruits where f_id in

(select f_id from fruits where f_price between 10 and 20);

例: 用any操作符与子查询语句来查询所有f_id对应的f_price在10元到20元之间的水果记录

select * from fruits where f_id = any

(select f_id from fruits where f_price between 10 and 20);

例: 用all操作符与子查询语句来查询所有f_price大于20元的水果记录

select * from fruits where f_price > all

(select f_price from fruits where f_price < 20);

例: 用exists操作符与子查询语句来查询是否存在f_price大于30元的水果记录

select * from fruits where exists

(select * from fruits where f_price > 30);

0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子