简体   繁体   English

mysql查询-没有更多条目具有相同的qID和相同的用户ID

[英]mysql Query - no more entries for same qID and same userID

The following description is a simple example with questions and answers. 以下描述是一个简单的示例,包含问题和答案。 But the logic of my site is similar. 但是我网站的逻辑是相似的。

Lets say tables are: 可以说表是:

USERS table: USER_ID, etc
QUESTIONS table: QUESTION_ID, TEXT, CATEGORY, CORRECT_RESPONSE, AVAILABLE
RESPONSES table: QUESTION_ID, USER_ID, RESPONSE_VALUE
PROFILE table: USER_ID, CATEGORY_Questions, YEAR, NUMBER_OF_ANSWERED, Number_OF_CORRECT, POINTS

The questions will be available to be answered by users for few hours. 用户可以在几个小时内回答这些问题。 Every question has the same 3 choices for answers YES/NO/DEPENDS. 每个问题的答案都是相同的3种选择:是/否/取决于。

So I want users to go click on one of them for example and store an entry on RESPONSES table (ok this query is easy) and then not be able to answer the same question again. 因此,我希望用户单击其中的一个并将其存储在RESPONSES表中(确定此查询很容易),然后无法再次回答相同的问题。 Users will be able to edit the question for some time and after this period I want the question to be shown as answered, until the end of the day that I will mark the question as AVAILABLE=NO and it will removed from the unanswered questions... What is the most efficient way to do this? 用户可以在一段时间内编辑问题,在此之后,我希望问题显示为已回答,直到一天结束,我将问题标记为AVAILABLE = NO,并将其从未回答的问题中删除。 ..什么是最有效的方法?

有很多的方式来实现这个要看具体情况,其中之一是创建一个布尔bit叫回答柱和另一列AnswerDate datetime or timestamp ,然后当用户回答一个问题添加答案的时间,然后使用PHP或JavaScript在处理更新所需时间过后,表中已answered的标志的数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM