I'm encountering difficulties when trying to insert data into my MySQL database using a batch script. Here's the script I'm currently using:
set query=INSERT INTO `my_tbl` (`age` ,`birthdate`) VALUES (15, NOW());
C:\wamp64\bin\mysql\mysql5.7.36\bin\mysql.exe -h localhost --user=root --password=SECRET -e "%query%" my_db
However, when I execute the script, I receive the following error message: VALUES was unexpected.
In addition to resolving the error, I would like to replace the static value of 15 with a variable.
The birthdate column is of timestamp data type, while the age column is of integer data type.
I added a variable called age and set it to 15 then i use it after values keyword. I hope it works.
Or if you want to align the command simply type