Guest User

Untitled

a guest
May 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. qotwQuestion1a(QuestionId [primarykey], Question, MemberId, PostDate);
  2. qotwVote1a (QuestionId [primarykey], MemberId [primarykey], Vote1a);
  3. qotwMember (MemberId [primarykey], Name, Password, emailId);
  4.  
  5. $result6 = mysql_query("SELECT MAX(Vote1a) AS highestVote, * FROM qotwMember, qotwQuestion1a , qotwVote1a
  6. WHERE qotwMember.MemberId=qotwQuestion1a.MemberId
  7. AND qotwQuestion1a.QuestionId=qotwVote1a.QuestionId
  8. AND qotwQuestion1a.MemberId=qotwVote1a.MemberId
  9. AND PostDate>='".$startofweek."' AND PostDate<='".$endofweek."'
  10. ORDER BY qotwQuestion1a.QuestionId DESC ");
  11. while($row6 = mysql_fetch_array($result6))
  12. {
  13. echo "The highest voted question of the last week is: "; echo $row6['highestVote']; echo $row6['MemberId'] . " " . $row6['Name'] . " " . $row6['Password'] . " " . $row6['PostDate'] . " " . $row6['Question']." ".$row6['QuestionId']." ".$row6['Vote1a'];
  14. echo "<br />";
  15. }
  16.  
  17. SELECT *
  18. FROM (
  19. SELECT q.QuestionId, q.MemberID
  20. FROM qotwQuestion1a q
  21. JOIN qotwVote1a v
  22. ON v.QuestionID = q.QuestionID
  23. WHERE PostDate BETWEEN $startdate AND $enddate
  24. GROUP BY
  25. q.questionID
  26. ORDER BY
  27. COUNT(*) DESC
  28. LIMIT 1
  29. ) qo
  30. JOIN qotwMember m
  31. ON m.MemberID = q.MemberID
Add Comment
Please, Sign In to add comment