library(RMySQL) conn <- dbConnect( MySQL(), user = dbuser, password = dbpass, dbname = dbname, host = dbhost, port = dbport ) query_frames <- " SELECT f.coins, CAST((f.elapsed_time / 1000) AS INT) FROM game g LEFT JOIN frame f ON (f.game_id = g.id) WHERE ( f.id = ( SELECT id FROM frame WHERE game_id = g.id ORDER BY elapsed_time DESC LIMIT 1 ) ) GROUP BY g.id; " query_get_players <- " SELECT id, name FROM player; " query_game_coin_vs_time <- " SELECT DISTINCT name, f.coins, CAST((f.elapsed_time / 1000) AS INT) as time FROM frame f LEFT JOIN game g ON (f.game_id = g.id) LEFT JOIN player p ON (g.player_id = p.id) WHERE ( f.game_id = ( SELECT id FROM game WHERE (won = 1) ORDER BY timestamp DESC LIMIT 1 ) ) ORDER BY f.elapsed_time ASC; " query_game_coin_vs_time_start <- " SELECT DISTINCT(CAST((f.elapsed_time / 1000) AS INT)) AS time, f.coins FROM frame f LEFT JOIN game g ON (f.game_id = g.id) WHERE ( f.game_id = ( SELECT id FROM game WHERE (player_id = " query_game_coin_vs_time_end <- " ) ORDER BY timestamp DESC LIMIT 1 ) ) GROUP BY CAST((f.elapsed_time / 1000) AS INT) ORDER BY f.elapsed_time ASC; "