You're right, but the OP didn't mention anything like that so I assume that there is only one SQL command in the script otherwise the OP should clarify his question.
I took the original poster's help request to mean that he wants a script that will take multiline input (from a user or standard input) and merge it into a single line which should be stored in the variable $query. I also assumed that the three-line sql fragment in the script was a poorly-placed sample of the input, as whether it's three lines or one, that code in a sh script will simply generate an error.
Proceeding under those assumptions, my proposed solution is:
#!/bin/sh
echo 'Enter your query (press Control-D when finished):'
query=$(tr -d \\n)
echo $query