Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. String email = Main_Login.accounttext.getText().trim();
  2. statement = (PreparedStatement) con
  3. .prepareStatement(""
  4. + "SELECT FILM,(film_total_ratings/number_of_ratings) as ratings_rating "
  5. + "FROM( "
  6. + "SELECT COUNT(*) as number_of_ratings, FILM, "
  7. + " SUM(RATING) as film_total_ratings "
  8. + " FROM ratings GROUP BY film "
  9. + "ORDER BY rating DESC"
  10. + ") TMP_Film");
  11. result = (ResultSet) statement.executeQuery();
  12.  
  13. int i = 0;
  14. while (result.next() && i <= 4) {
  15.  
  16. i++;
  17. // if (result.getString(1).contains(email)) {
  18.  
  19. System.out.println((i) + ")" + " " + "[Movies You Might Like]"
  20. + " " + result.getString(1) + " " + "[Rating]" + " "
  21. + result.getString(2));
  22.  
  23. statement = (PreparedStatement) con
  24. .prepareStatement(""
  25. + "SELECT FILM,(film_total_ratings/number_of_ratings) as ratings_rating "
  26. + "FROM( "
  27. + "SELECT COUNT(*) as number_of_ratings, FILM, "
  28. + " SUM(RATING) as film_total_ratings, "
  29. + " SUM(CASE WHEN EMAIL LIKE '%"+email+"%' THEN 1 ELSE 0 END) as rated"
  30. + " FROM ratings GROUP BY film HAVING rated=0 "
  31. + "ORDER BY rating DESC"
  32. + ") TMP_Film");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement