Sql 编写高级过滤系统
这是我的关系 用户希望能够使用下拉菜单添加过滤器,并相应地过滤志愿者。筛选器来自Sql 编写高级过滤系统,sql,ms-access,vba,Sql,Ms Access,Vba,这是我的关系 用户希望能够使用下拉菜单添加过滤器,并相应地过滤志愿者。筛选器来自志愿者工作区表(志愿者工作区ID)。我这样做很痛苦,可能是因为缺乏知识。每次用户添加新过滤器时,我都必须以复杂的方式更改SQL。例如,这是用户添加三个过滤器后的SQL SELECT DISTINCT Volunteer.VolunteerId AS Volunteer_VolunteerId , Volunteer.VolunteerFirstName , Volun
志愿者工作区
表(志愿者工作区ID
)。我这样做很痛苦,可能是因为缺乏知识。每次用户添加新过滤器时,我都必须以复杂的方式更改SQL。例如,这是用户添加三个过滤器后的SQL
SELECT DISTINCT
Volunteer.VolunteerId AS Volunteer_VolunteerId ,
Volunteer.VolunteerFirstName ,
Volunteer.VolunteerLastName ,
Volunteer.VolunteerOtherName ,
Volunteer.VolunteerStreetAddress ,
Volunteer.VolunteerSuburb ,
Volunteer.VolunteerPostCode ,
Volunteer.VolunteerHomePhone ,
Volunteer.VolunteerMobilePhone ,
Volunteer.VolunteerGender
FROM Volunteer
INNER JOIN ( VolunteerWorkArea
INNER JOIN VolunteerWorkAreaAllocation ON VolunteerWorkArea.VolunteerWorkAreaId = VolunteerWorkAreaAllocation.VolunteerWorkAreaId
) ON Volunteer.VolunteerId = VolunteerWorkAreaAllocation.VolunteerId
WHERE VolunteerWorkAreaAllocation.[VolunteerWorkAreaId] = 17
AND Volunteer.VolunteerId IN (
SELECT DISTINCT
Volunteer.VolunteerId
FROM Volunteer
INNER JOIN ( VolunteerWorkArea
INNER JOIN VolunteerWorkAreaAllocation ON VolunteerWorkArea.[VolunteerWorkAreaId] = VolunteerWorkAreaAllocation.[VolunteerWorkAreaId]
) ON Volunteer.[VolunteerId] = VolunteerWorkAreaAllocation.[VolunteerId]
WHERE VolunteerWorkAreaAllocation.[VolunteerWorkAreaId] = 16
AND Volunteer.VolunteerId IN (
SELECT DISTINCT
Volunteer.VolunteerId AS Volunteer_VolunteerId
FROM Volunteer
INNER JOIN ( VolunteerWorkArea
INNER
JOIN VolunteerWorkAreaAllocation ON VolunteerWorkArea.[VolunteerWorkAreaId] = VolunteerWorkAreaAllocation.[VolunteerWorkAreaId]
) ON Volunteer.[VolunteerId] = VolunteerWorkAreaAllocation.[VolunteerId]
WHERE VolunteerWorkAreaAllocation.[VolunteerWorkAreaId] = 15 ) );
所以每次用户添加过滤器时,我都必须通过代码大量更改SQL。我确信有一个简单的方法可以做到这一点。有人能帮我吗?谢谢 如果您希望用户根据志愿者工作区决定志愿者,那么更简单的解决方案是使用子表单
您有几个连接
V
、VWAA
和VWA
的实例,我建议您将它们“封装”到一个视图中,以简化一些事情。非常抱歉,反应太晚了。我离开它有一段时间了:(