WORKAROUND:
I managed to fix this by deleting the msg.payload from my input and then it is working.
So it works properly when I pass exactly the same input without msg.payload.
In that case I didn't get the error and FYI the query returned the following:
It took me quite some time to figure out that the msg.payload was causing this.
Maybe it would be good to update the documentation or make the implementation independent from the msg.payload passed as input when "Via msg.topic" is used.
Digging into this more, the code that I believe causes this issue was added back in January 2015 (see Redirecting to Google Groups) to deal with binding.
Binding parameters is important with any database. You can use your fav. search engine to lookup why - in short SQL injection, on purpose or accidental. It could be as simple as generating a query with "Today's bug" in a string, and now you have broken SQL because of the single quote - sure you can put in a regex that says change all single quotes to double - but that is SQLite specific, move to MySLQ and you have to change all your code.
@dceejay the question is how to determine if the sql is in msg.topic but not using a binding?