日期:2014-05-16 浏览次数:21054 次
SELECT A.学生ID ,
B.课程ID
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY 学生ID ) ID ,
学生ID
FROM a
) A
INNER JOIN ( SELECT ROW_NUMBER() OVER ( ORDER BY 课程ID ) ID ,
课程ID
FROM B
) B ON A.ID = B.ID
select
a.学生名称,b.课程名称
from
a inner join c on a.学生ID=c.学生ID
inner join b on b.课程ID =c.课程ID
--insert into C(学生ID , 课程ID)
select a.学生ID,b.课程ID
from A
inner join b
on 1=1 and a.学生名称 = 'xxx' and b.课程名称 = 'yyy'
where not exists(select 1 from c
where c.学生ID = a.学生ID and c.课程ID = b.课程ID)