I am writing a bash script to update a MySQL table using a previously defined variable. For some weird reason, the value that is populated in the table does not match the value of the variable. Here is my code:
var_date="2007-03-15"
mysql -u username -ppassword dbname -e "update customer_description set visit_date = ${var_date};"
The second line basically updates the MySQL table so that the "visit_date" column is set to $var_date. In this case, the visit_date column should be set to "2007-03-15". However, when I ran this script, the visit_date column was set to "1986". I have no idea where "1986" came from, but for some reason "2007-03-15" was replaced with "1986". Does anyone know why this would happen?
P.S. The MySQL datatype of the visit_date column is a varchar(20), meaning a variable-length string with a maximum length of 20 characters.
var_date="2007-03-15"
mysql -u username -ppassword dbname -e "update customer_description set visit_date = ${var_date};"
The second line basically updates the MySQL table so that the "visit_date" column is set to $var_date. In this case, the visit_date column should be set to "2007-03-15". However, when I ran this script, the visit_date column was set to "1986". I have no idea where "1986" came from, but for some reason "2007-03-15" was replaced with "1986". Does anyone know why this would happen?
P.S. The MySQL datatype of the visit_date column is a varchar(20), meaning a variable-length string with a maximum length of 20 characters.