本文介绍了想要加入两个表,但我的查询不起作用,任何人都可以帮助,来自两个表的Iwant数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有两个表我还想要来自表2的数据。即大学必须通过使用申请表编号和表2中的
字段来匹配表1(ApplicationForm)(ApplicationFormSuppliment_phy)是applicationno,userID,university,other university,prnno
there are two tables I also want data from table no 2. i.e university which must match to table no 1(ApplicationForm ) by using application form number and
fields in table no 2(ApplicationFormSuppliment_phy) are applicationno,userID,university,other university,prnno
SELECT [ApplicationNumber],[Surname]
,[Firstname]
,[Middlename],[Gender],[State],[UniversityBoard]
FROM dbo.ApplicationForm
AS a
INNER JOIN dbo.ApplicationFormSuppliment_phy AS p
ON a.Userid = p.UserId
where DeptId='17' and SubjectId='27'
ORDER BY p.ApplicationNo
推荐答案
select [A].*, [P].*
from
[Application] as [A]
inner join [ApplicationFormSupplement_Phy] as [P]
on [P].[UserID] = [A].[UserID]
and [P].[ApplicationNo] = [A].[ApplicationNumber]
where
[A].[DeptID] = '17'
and [A].[SubjectID] = '27'
order by [A].[ApplicationNumber]
这篇关于想要加入两个表,但我的查询不起作用,任何人都可以帮助,来自两个表的Iwant数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!