I managed to track back why the query works on some systems and doesn’t work on some others. I think it’s related to the magic_quotes setting in php.ini; if you have magic_quotes active, mysql gets the following query:
SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_type = 'attachment' AND wp_posts.post_parent = 5 AND (post_mime_type LIKE 'image/%') GROUP BY wp_posts.ID ORDER BY \"menu_order ASC, ID ASC\" DESC
The \” of course renders the query invalid.