数据库,多表查询
发布网友
发布时间:2022-05-03 09:38
我来回答
共2个回答
热心网友
时间:2022-05-03 11:07
CREATE PROCEDURE p_SelectStudentInfo
(
@Flag int,
@StuName nvarchar(20)
)
AS
IF @Flag=1//精确
BEGIN
SELECT StuNo'学号',StuName'姓名',Pwd'密码',ClassName'所在班级',Student.ClassNo FROM Student,Class WHERE Student.ClassNo=Class.ClassNo AND StuName=@StuName
END
IF @Flag=2//模糊
BEGIN
SELECT StuNo'学号',StuName'姓名',Pwd'密码',ClassName'所在班级',Student.ClassNo FROM Student,Class WHERE Student.ClassNo=Class.ClassNo AND StuName LIKE '%'+@StuName+'%'
END
根据姓名 和判断条件查找(精确查找或模糊查找)
热心网友
时间:2022-05-03 12:25
select student.* from student
left join status on status.id=student.id
left join student_statue on student_status.status=status.id
where student.id=xxx;