sql 复杂查询

table1表

table 1 

a b c

1 2 4
1 3 4
2 3 3
2 5 5

table2表

d e f

4 1 1
4 2 2
5 5 5

1.查询出table1 表中a列相同b列最小值

查询出的结果如下:

1 2
2 3

查询语句:SELECT a ,min(b) from table1 GROUP BY  a

2.查询出table2表中c列在table1中不存在的列 假如table2中数据有1000万条

SELECT * from table1 where NOT EXISTS ( SELECT table2.c from table2 where table2.c=table1.c)

 

posted on 2015-12-02 09:51  悄悄的来,匆匆的走  阅读(263)  评论(0编辑  收藏  举报

导航