When this string is decoded from its html entity encoded form it becomes the following:
25' having 1=1--
This string, when placed as is into, for example, the following (PHP) database query function:
mysql_query("SELECT * FROM users WHERE username = '$username'");
Becomes this:
mysql_query("SELECT * FROM users WHERE username = '25' having 1=1--'");
Note here that the %27 (') breaks out of the argument in the WHERE clause and continues the executable part of the statement. The -- after 1=1 makes the rest of the statement a comment which is not executed.
The HAVING statement in SQL is supposed to be used within queries which use the GROUP BY operator, and should fail in queries which do not. My guess here is that this string is being used to check simply for the presence of an unsanitised variable which gets placed into an executed query.
To prevent this type of attack I would suggest using a good input sanitation function, or parameterised queries. The implementation of this depends on the programming environment in question.
Addition: The normal use of 1=1 in SQL injection queries is to cause all rows to be returned, voiding any other WHERE conditions. An example input could be:
a' OR 1=1 --
When inserted as the $password parameter in a query such as:
SELECT * FROM users WHERE username = '$username' AND password = '$password'
The statement becomes:
SELECT * FROM users WHERE username = 'mark' AND password = 'a' OR 1=1 --
The resulting dataset will include all entries in the 'users' table, as 1=1 is always true.