Sorry - I've just looked at this again and you don't need the prefix on the table in the select statement (I've had so many problems with table prefixes in my stats plugins that I saw a table name and thought 'prefix') and this may solve the problem.