与在MS Access中组合SubQuery和加入相关的问题

时间:2012-12-21 06:48:32

标签: sql database ms-access

  

可能重复:
  Isssue Related to Join in MS Access Database

我在MS-Access数据库文件中有一个数据库文件..

我有以下查询:

Select RGN.rgn_regionId,RGN.rgn_titleGuj AS Center,

(Select COUNT(*) from (select Distinct PRS.prs_personId From tb_personDepartment PD,tb_person PRS Where PD.pd_designationId = 1 And PD.pd_personId = PRS.prs_personId And PRS.prs_centerId = RGN.rgn_regionId And PRS.prs_attandanceStatus = 'Y')) As SKAt

From tb_person PRS,tb_personDepartment PD,tb_region RGN
Where PD.pd_personId = PRS.prs_personId
And PRS.prs_centerId = RGN.rgn_regionId
Group By RGN.rgn_regionId,RGN.rgn_titleGuj

表结构如下

select * from tb_person where prs_personId in (3)
--prs_personId   prs_uniqId prs_centerId prs_fName  prs_mName    prs_lName  prs_age   prs_addres   prs_areaId
-- 3                    1       1               abc     abc             abc         12      andn            2
--(1 row(s) affected)

    select * from tb_personDepartment where pd_personId in (3)

    --pd_personId          pd_mahotsavId pd_departmentId pd_designationId pd_MainSK
    ---------------------- ------------- --------------- ---------------- -----------
    --3                    1             41              1                1
    --3                    1             44              2                0
    --3                    1             104             1                1

--(3 row(s) affected)

select * from tb_personMahotsavDetail where pm_personId in (3)

--pm_personId   pm_mahotsavId pm_personStatus pm_sevaDaysH   pm_accommodationRequired pm_utaraPlace  
--------------- ------------- --------------- -------------- ------------------------ -------------  
--3                    1             SS              8           0                        NULL       

--(1 row(s) affected)

select * from tb_person where prs_personId in (3)
-- Single Record

select * from tb_personDepartment where pd_personId in (3)
-- Multiple Record With Same Person Id

select * from tb_personMahotsavDetail where pm_personId in (3)
-- Single Record

1 个答案:

答案 0 :(得分:0)

发生了这种情况 column name does not existmisspelled时可能{。}}。