CREATE TABLE Subject_Marks
(
Marks_ID int primary key,
Maths_Score int,
Science_Score int,
Social_Score int,
English_Score int,
SUPW_Score int,
Student_ID int not null
);
INSERT into Subject_Marks VALUES
(1,1001, 50, 99,98,45,57);
无法将此表与下面显示的其他表联接。
CREATE TABLE Student_Data
(
Student_ID int IDENTITY(1001,1) PRIMARY KEY,
Student_Name VARCHAR(20) NOT NULL,
Student_Address VARCHAR(100),
Student_Phone bigint,
Student_Email VARCHAR(30),
college_id int NOT NULL
);
答案 0 :(得分:0)
由于Student_ID是提供关系的键,因此需要在联接中使用它。因此,您需要为SQL Server构建如下所示的联接:
select sd.* , sm.*
from Student_Data sd
inner join Subject_Marks sm on sm.Student_ID = sd.Student_ID