请教一条mysql的sql语句怎么写

表1: project
id projecName reportID
1 火电 1
2 水电 1
3 风电 1
4 火电 2
5 水电 2
6 核电 2
7 光电 1
表2:report
id time
1 2016年04月
2 2016年05月

想查出来2016年04月上报的projectName,但是05月份没有上报的
即:
id projectName

3 风电
7 光电
mysql数据库,表2的id 对应的表1 reportID
同时请教,我用的是绿色版的mysql32位的,project和report表都有大量数据的时候,执行查询的时候没有反应是为什么?

select * from project where projecName not exist(select projecName from project where reportID=2)

从表里看出来,表1的reportID=表2的id所以根据这个关联可以写出来
sql=select 表1.id from 表1,表2 where 表1.reportID=表2.id AND 表2.id=1

select projecName from project where reportID =(select id from report where time=' 2016年04月')

创建表字段名的时候要注意,有些是 数据库关键字,最好不要用

select a.id,a.projectName from project a
left join report b on b.id = a.reportID
where b.time = '2016年04月'
and a.projectName not in (
select a.projectName from project a
left join report b on b.id = a.reportID
where b.time = '2016年05月'
)

 SELECT * FROM project 
    WHERE reportID IN (SELECT id FROM report WHERE time = '2016年04月') 
    AND projecName NOT IN (SELECT projecName FROM project WHERE reportID IN (SELECT id FROM report WHERE time = '2016年05月') )

SELECT * FROM(SELECT * FROM project WHERE time = 201604 )as p1 LEFT JOIN ( SELECT * FROM project WHERE time = 201605 ) as p2 on p1.projecName=p2.projecName WHERE p2.projecName IS NULL

select * from project where reportID=(select id from report where time='2016年04月') not exist(select * from project where reportID=(select id from report where time='2016年05月'))

select * from project where reportID = (select id from report where time='2016年04月')
and projecName not in(
select projecName from project where reportID = (select id from report where time='2016年05月')
)

select * from project where reportID = (select id from report where time='2016年04月') and reportID <>(select id from report where time='2016年05月')
试试

select projectName from project where reportID in (select id from report where time='2016年04月')