Instead of using $(hostname) directly, assign it to a shell variable so you can use PE expressions at expansion time:
hostname=$(hostname)
updatevar="... ${hostname%%.*} ..."
The use of %%.* trims everything after the first dot. You could instead use ${hostname%.com} if you only wanted to remove the suffix .com (but leave .org, .net, etc alone).
Alternately, instead of $(hostname), use $(hostname -s) if your operating system supports it; this is the "short" form, truncated at the first dot.
That said -- using string substitutions to form SQL expressions is bad form (and since bash doesn't typically give you a way to use bind variables in running SQL, it's usually necessary/appropriate to use a different language if you genuinely want to do the job right). Even the Wooledge bash guide explicitly calls out database interaction as a limitation.