May seem like a step backwards, but there is some code that could be added to your store which will identify where that query is being run that is wrongly formatted. For some reason it is trying to find the actual text that is to be substituted by the table information.

Lat9 created it, the plugin has the name mydebug in it... I think... Basically it tells you which file sent the query.