1. 表结构太乱,看不出来,我另外写一个结构吧:
Teacher:ID Name
Student:ID Name TeacherID
select Student.*,Teacher.Name from Student,Teacher where Teacher.ID = 指定教师的ID and Student.TeacherID = Teacher.ID以下的表结构:
A:ID Data
B:ID Data
2. select * from A where Data not in (select Data from B)
3. delete from A where Data in (select Data from B)
Teacher:ID Name
Student:ID Name TeacherID
select Student.*,Teacher.Name from Student,Teacher where Teacher.ID = 指定教师的ID and Student.TeacherID = Teacher.ID以下的表结构:
A:ID Data
B:ID Data
2. select * from A where Data not in (select Data from B)
3. delete from A where Data in (select Data from B)
Teacher:ID Name
Student:StudID Name ID(连结Teacher中的ID)
select * from student,teacher
where student.id=teacher.id and teacher.name='教师名'
2.表结构:
A:ID Data
B:ID Data
SELECT *
FROM A
WHERE EXISTS
(SELECT *
FROM B
WHERE A.id= B.id and A.Data=B.Data)
3.表结果同上
delete
FROM A
WHERE EXISTS
(SELECT *
FROM B
WHERE A.id= B.id and A.Data=B.Data)
select A.title from A,B
where A.title<>B.title
order by A.title
这个可能不太好,要不用下面的:
select A.title from A
where title NOT IN (SELECT DISTINCT title from B);3、
delete A
where A.title=B.title
left outer join student on teacher.id=student.id
where teacher.name='老师姓名'2.select * from a where not exits
(select * from b where b.id=a.id)3.delete from a where exists
(select * from a
union
select * from b)