如何理解SQL中的自连接?
点击关注上方“SQL数据库开发”,
设为“置顶或星标”,第一时间送达干货
SQL专栏
SELECT
s1.Sname AS Sname1,
s2.Sname AS Sname2
FROM Student s2,Student s1
SELECT
s1.Sname AS Sname1,
s2.Sname AS Sname2
FROM Student s2,Student s1
WHERE s1.Sname=s2.Sname
SELECT
s1.Sname AS Sname1,
s2.Sname AS Sname2
FROM Student s2,Student s1
WHERE s1.Sname<>s2.Sname
SELECT
s1.Sname AS Sname1,
s2.Sname AS Sname2
FROM Student s2,Student s1
WHERE s1.Sname>s2.Sname
SELECT
IDENTITY(INT) ID,
Sname,
Score
INTO Student_Tmp
FROM Student
DELETE FROM Student_Tmp
WHERE Student_Tmp.ID< (
SELECT Max(s2.ID)
FROM Student_Tmp s2
WHERE Student_Tmp.Sname=s2.Sname
AND Student_Tmp.Score=s2.Score
);
SELECT DISTINCT * INTO Student_Tmp FROM Student
TRUNCATE TABLE Student
INSERT INTO Student SELECT * FROM Student_Tmp
DROP TABLE Student_Tmp
推荐阅读
悟空无姓无名的时候,阎王生死簿是怎么写的呢? 5号发工资和25号发工资,还能看出公司是否靠谱?🤫 如果把14亿中国人都拉到一个微信群。。。 四款可视化工具,解决99%的可视化大屏需求 假如面试中大家都说实话....
后台回复关键字:1024,获取一份精心整理的技术干货
后台回复关键字:进群,带你进入高手如云的交流群
评论