T-SQL from后面多表查询

USE [test]
GO
--创建表
CREATE TABLE MyClass
(
	ClassID VARCHAR(36) PRIMARY KEY,
	ClassName NVARCHAR(200)
)

CREATE TABLE MyStudent
(
	StudentID VARCHAR(36) PRIMARY KEY,
	StudentName NVARCHAR(200),
)
--插入信息
INSERT INTO MyClass(ClassID,ClassName)VALUES('0AD2A12E-423E-49BF-A265-1A84B21C2401','一班');
INSERT INTO MyClass(ClassID,ClassName)VALUES('0AD2A12E-423E-49BF-A265-1A84B21C2402','二班');
INSERT INTO MyStudent(StudentID,StudentName)VALUES('FDA251AE-2ACE-4449-8FAC-17D769BEF801','张三');
INSERT INTO MyStudent(StudentID,StudentName)VALUES('FDA251AE-2ACE-4449-8FAC-17D769BEF802','李四');
--简单查询
SELECT * FROM MyClass
SELECT * FROM MyStudent
--两张表关键查询
SELECT * FROM MyClass,MyStudent

 

你可能感兴趣的:(sql,server,T-SQL,多表)