Doing a trace with MySQL will definitely show you the query. I don't know about other DBs. I guess it's better to test your query first then copy/paste it into perl code. Even still, it's frustrating to get "error in your sql syntax" but not have the actual query in front of you to look at.