复杂过滤器...... [英] Complex filters...

查看:64
本文介绍了复杂过滤器......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已设置数据库以记录一组问题的答案。为了允许对问题的多个答案,我决定将结果存储在另一个表中,格式如下。


响应ID,问题ID,答案ID

(还有其他几个字段,但它们不相关)


这适用于存储响应,它允许我有尽可能多的问题,每个人都有尽可能多的答案。


不幸的是我没想到如何报告这些信息。显然,找出用特定答案回答特定问题的人数很容易,但我的经理现在已经声明她想要交叉参考问题。


例如,如果其中一个问题是?你在A公司或B公司工作吗? (问题ID 1)和可能的答案是是和否(答案ID 1和2)


这需要交叉引用另一个问题?哪个网站遇到了问题? (问题ID 2)并且有10个可能的答案(答案ID 3-13)


我知道我需要做什么,但我不知道我会做什么Access中的这个。


基本上我需要过滤所有问题ID 1的表格,答案是答案ID 1.(互联网出现问题的人)。使用这个过滤器,我需要记录响应ID?这对于互联网有问题,并使用此列表在表上进行另一个过滤。 (所以这个新过滤器现在会显示对第一个问题回答是的所有人的完整回复)


例如


响应ID,问题ID,答案ID


1,1,1

1,2,5

1,2,6

1,2,9

2,1,1

2,2,5

2,2,6

3,1,2

4,1,1

4,2,9

5,1 ,2


这将是5人响应的表格的内容。

3位受访者回答是问题1

2位受访者回答否问题1.


I现在需要为任何问题ID 1过滤此列表,其中答案ID也是1.(此示例的此过滤器的结果将是:


1,1,1

2,1,1

4,1,1


显然这并不是很有用,因为它已经过滤了所有的其他问题,但它所做的是为我提供了对问题1(1,2和4)回答是的响应ID列表。在这个例子中只有3个,但这可能是1000个)


到目前为止我还没达到这一点。执行初始过滤很容易 - 我现在需要知道的是,是否可以从过滤器中第一个字段的内容生成另一个过滤器?然后显示来自那些特定受访者ID的所有数据?

(1,2和4)


这将是:


1,1,1

1,2,5

1,2,6

1,2,9

2,1,1

2,2,5

2,2,6

4,1,1

4,2 ,9

我现在可以做另一个过滤器来查找交叉引用的答案,例如哪个特定的网站导致了这个问题。


现在我必须解释一下这只是一个示例问题,系统目前正在设计中,因此它有一个完整的管理部分,您可以在其中设计问题和答案集,因此需要交叉引用的问题和答案可能与任何事情有关。每个问题都可能出现?会有更多的问题和可能的答案。


我知道这很复杂,我可能没有解释得那么好,但任何帮助指出我正确的方向(甚至非常感谢。告诉我它是不可能的。

解决方案

过滤器可以有多长时间限制?


例如


" 1"或2或2。或者3....


如果可以通过读取过滤表中的第一个字段然后使用它来提交另一个表来弥补,那么这是可能的。


如果存在限制,这实际上不是一个可行的选项,因为我需要在过滤器中最多1000个数字,以确保数据库生成准确的报告。


如果有一种方法可以根据另一个过滤表中每条记录的内容过滤表格会容易得多。


如果你问的话有没有办法根据另一个查询的结果筛选一个查询?,那么答案是肯定的。


你不会使用OR而是使用In()代替。让我看看我是否能想出一个简单的例子来反映你原来的问题。


我建议你在同一时间查找In()函数&子查询( SQL中的子查询),以便更好地了解其工作原理。

我刚刚在您的数据中注意到[响应ID] 1& 2对于[问题ID]都有多个答案2.这有意义吗?

这不应该影响使用的方法,但我认为无论如何都会标记它。


I have set a database up to record the answers to a set of questions. In order to allow multiple answers to a question I decided to store the results in another table in the following format.

Response ID, Question ID, Answer ID

(There are another few fields but they?re not relevant)

This works fine for storing the responses, it allows me to have as many questions as I need, each with as many answers as I need.

Unfortunately I did not think about how I could report on this information. Obviously finding out the number of people who answered a particular question with a particular answer is easy but my manager has now stated that she wants to cross reference questions.

For example, if one of the questions were ?Do you work for company A or B?? (Question ID 1) and the possible answers were Yes and No (answer ID 1 and 2)

This would need cross referencing with another question ?Which website/s experienced the problems? (question ID 2) and there are say 10 possible answers (Answer ID 3-13)

I know what I need to do, but I just don?t understand who I would do this in Access.

Basically I need to filter my table for all Question ID 1 where the answer was Answer ID 1. (People who had a problem with the internet). Using this filter I need to make a record of the Response ID?s which had a problem with the internet and use this list to make another filter on a table. (so this new filter would now show the full response for everyone who had answered yes to the first question)

e.g.

Response ID, Question ID, Answer ID

1,1,1
1,2,5
1,2,6
1,2,9
2,1,1
2,2,5
2,2,6
3,1,2
4,1,1
4,2,9
5,1,2

This would be the contents of a table where 5 people had responded.
3 of the respondents have answered Yes to question 1
2 of the respondents have answered No to question 1.

I now need to filter this list for any Question ID 1 where the Answer ID is also 1. (The result of this filter for this example would be:

1,1,1
2,1,1
4,1,1

Obviously this isn?t really helpful as it has filtered out all of the other questions, but what it has done is provided me with a list of the response ID who has answered yes to question 1 (1,2 and 4). In this example there is only 3, but this could potentially be 1000)

So far im fine up to this point. Performing the initial filter is easy - What I need to know now is, is it possible to generate another filter from the contents of the first field in my filter? Then displaying all of the data from those particular respondent ID?s?
(1,2 and 4)

This would be:

1,1,1
1,2,5
1,2,6
1,2,9
2,1,1
2,2,5
2,2,6
4,1,1
4,2,9

Which I could now do another filter on to find out cross referenced answers, such as which particular websites caused the problem.

Now I must explain that this is just an example question, the system is currently designed so it has a full admin section where you can design questions and answer sets, so the question and answers needing cross-referenced could potentially be about anything. It is likely that each question?set? would have many more questions and possible answers.

I know this is quite complicated and i?ve probably not explained it that well but any help to point me in the right direction (or even tell me it?s not possible) would be greatly appreciated.

解决方案

Is there a limit to how long a filter can be?

e.g.

"1" or "2" or "3"....

If one could be made up by reading the first field in the filtered table and then using that to filer another table then this would be possible.

If there is a limit this would not really be a viable option since I would need upto 1000 numbers in the filter to ensure that the database produces accurate reports.

It would be much easier if there was a way to filter a table based on the contents of each record in another, filtered table.


If you''re asking "Is there a way to filter one query depending on the results of another?", then the answer is yes.

You wouldn''t use OR but In() instead. Let me see if I can come up with a simple example reflecting your original question for you.

I suggest, in the mean time, you look up the In() function & subqueries (Subqueries in SQL) to get a better understanding of how it works.


I''ve just noticed in your data that [Response ID]s 1 & 2 both have multiple answers for [Question ID] 2. Does this make sense?
This shouldn''t effect the method to use, but thought I''d flag it anyway.


这篇关于复杂过滤器......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆