Bash: assign a multi-line string to a variable

Sometimes you need multi-lined strings for readability in your scripts. I needed it for scripts that execute SQL queries.

Example of a simplified script:

#!/bin/bash

read -d '' QUERY <<EOF
UPDATE table_name SET
 field1 = 'value',
 field2 = 'value'
 WHERE id = 1;
EOF
mysql table_name -e "$QUERY"