Hello I'm fairly new to SQL so i have a mySQL database set up and ive figured out how to most of the things that im trying to do, but im really struggling with this one problem. I am creating a league website using PHP and mySQL, ive got most of it pretty much done, but i want to be able to show some basic statistics about each league. I want to be able to show how many games each player in a particular event has played in the past 7 days, so basically I have 2 tables:
i was trying to use a count to count the occurences of each name in playerA and playerB and join along with results.date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) to determine results in the last week, but couldnt get near the output im after. I'd be greatful if anyone could help me out, thanks
Last edited by RMK147; 03-24-2012 at 04:03 PM.
Reason: spacing
i got it working but using a sub query, if any1 could convert it to using joins that would be even better
SELECT playerName, (SELECT COUNT(*) FROM results WHERE (playerName = playerA OR playerName = playerB) AND date >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)) AS weeklyGames FROM entrants WHERE eventID = '1'
Bookmarks