select * from eric_member a
where class_e='0601'
and not exists (
select 1 from rating_result
where st_id=a.eric_username
--and class =a.class_e --没说清楚,也许不用,也许用
and subject ='数学'
)eric_member表中报有“数学”的也行,
select * from eric_member a
where class_e='0601'
and exists (
select 1 from rating_result
where st_id=a.eric_username
--and class =a.class_e --没说清楚,也许不用,也许用
and subject ='数学'
)
where class_e='0601'
and not exists (
select 1 from rating_result
where st_id=a.eric_username
--and class =a.class_e --没说清楚,也许不用,也许用
and subject ='数学'
)eric_member表中报有“数学”的也行,
select * from eric_member a
where class_e='0601'
and exists (
select 1 from rating_result
where st_id=a.eric_username
--and class =a.class_e --没说清楚,也许不用,也许用
and subject ='数学'
)
即 数学中(eric_member-rating_result)的eric_username
求这样一个查询语句,
select * from eric_member a ,
(select eric_username,class_e , eric_username+class_e as c from eric_member where c not in (select st_id + class as c from rating_result where subject='数学')) b
where a.eric_username = b.eric_username and a.class_e = b.class_e
另外如果能查询eric_member表中报有“数学”的也行,
表的结构不改,不要说在eric_member在加字段的做法
select * from eric_member a ,
(select eric_username,class_e , eric_username+class_e as c from eric_member where c in (select st_id + class as c from rating_result where subject='数学')) b
where a.eric_username = b.eric_username and a.class_e = b.class_e