I really don't like this bit of code - it's not immediately obvious that %1 might be an extra (WHERE) clause.