As others have noted, it looks ok. You can have columns in WHERE not referenced in the results set. Note that most RDBSMs won't allow a column reference in a sort that isn't in the select. But that's not your problem.
Two suggestions:
- Paste the generated SQL into an ISQL client and see if it runs. If so, there's a DBI or other Perl / MySql issue.
- If not, then start with a very simle query and add pieces one at a time to see where it breaks.
hth