I have a table variable in shell-script which contains '&'. When I try to update the table in shell script the query fails.
I have tried several options to embrace the table name with single quotes, double quotes, back quote '`' (back quote considers the statement in it as a command to shell)
Also tried setting below options: set define on set escape on
#!/bin/bash
Table='City_&_District'
mysql --user=$DB_USER --password=$DB_PASSWD $DB_NAME << EOF
update $Table set Actual='$Actual', Normal='$Normal', Dep_Per='$Dep', Cat='$Cat' where Date='$Date';
EOF
If I Input Table name as: 'City' the query succeeds If I Input Table name as: 'City_&_District' the query Fails
ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&_District set Actual='0.4', Normal='0.1', Dep_Per='340%', Cat='LE' where Date='' at line 1