这是我在存储过程中的查询
DECLARE @branch uniqueidentifier
SELECT @branch = Branch_Id
FROM Student_Master
WHERE Student_Id = @studentid
SELECT
CompanyMaster.unique_id_company,
Job_College.College_Id,
Job_Branch.Branch_Id,
CompanyMaster.name,
Job_Master.Job_Post_Date, Job_Master.Job_Title,
Job_Master.Salary, Job_Master.Job_Location,
Department_Master.Department_Name
FROM
Job_Master
INNER JOIN
Company_Master ON Job_Master.Company_ID = CompanyMaster.unique_id_company
INNER JOIN
Department_Master ON Department_Master.Department_Id = Job_Master.Department_Id
INNER JOIN
Job_College ON Job_Master.Job_ID = Job_College.Job_Id
INNER JOIN
Job_Branch ON Job_Branch.Job_College_ID = Job_College.Job_College_ID
WHERE
Job_Branch.Branch_Id = @branch
逻辑查询是正确的,并且如果我将@branch
的值直接传递给它(而不是在开头使用SELECT
查询),则产生预期的结果但是通过填充值的代码显示此方法@branch
在开头使用选择查询时,此查询会产生0结果,尽管@branch
正在从中获取值。
我尝试过的事情
请帮忙!!我被困了好几个小时