建表语句点击详见
– 查询学过编号为"01"但是没有学过编号为"02"的课程的同学的信息
SELECTst.* FROM student st
JOIN score sc
ON st.s_id = sc.s_id AND sc.c_id='01'
WHERE st.s_id NOT IN (
SELECT
st.s_id
FROM student st
JOIN score sc
ON st.s_id = sc.s_id AND sc.c_id='02');
建表语句点击详见
– 查询学过编号为"01"但是没有学过编号为"02"的课程的同学的信息
SELECTst.* FROM student st
JOIN score sc
ON st.s_id = sc.s_id AND sc.c_id='01'
WHERE st.s_id NOT IN (
SELECT
st.s_id
FROM student st
JOIN score sc
ON st.s_id = sc.s_id AND sc.c_id='02');