We read your photo as:
How do I fix SQL error 1064 for INSERT statements in MySQL, specifically related to column names, string formatting, and generated columns?
Computer Science
ScanSolve AI Answer
Step-by-step solution
2 stepsThe error ERROR 1064 (42000): You have an error in your SQL syntax is occurring for a few reasons:
- Incorrect Column Name: In the previous step, the
HireDatecolumn was renamed toDOE. YourINSERTstatement for theEmployeetable still usesHireDate. - Syntax for String Literals: In your
VALUESclause forEmployee,'Erasmus, 'Iiyambo'is incorrectly formatted. Each string literal needs to be enclosed in single quotes and separated by commas. It should be'Erasmus', 'Iiyambo'. - Generated Column: The
BonusMonthcolumn is a generated column and should not be included in theINSERTstatement's column list orVALUES. It will be automatically calculated based on theDOE. - Multiple Statements: Each
INSERTstatement needs to be executed separately, typically by ending each with a semicolon.
Here are the corrected SQL commands to add the new employee and their salary:
Insert the new employee into the
Employeetable.Note that
HireDateis changed toDOE, andBonusMonthis omitted as it's generated.Insert the salary details for the new employee into the
Salarytable.Execute these two commands one after the other.
Was this helpful?
Still stuck on this one?
Ask a follow-up, and the answer starts from this question.
Got a different question?Ask your own question
More Computer Science Questions
QHow to fix "ERROR 1064 (42000): You have an error in your SQL syntax" when inserting into a MySQL…QHow do I fix the SQL error 'ERROR 1064 (42000): You have an error in your SQL syntax' when inserting…QHow to fix SQL syntax error when inserting data with column names containing spaces in MySQL?QHow to rename a column that is part of a generated column dependency in MySQL?QHow to fix the MySQL error "Out of range value for column 'BonusMonth'" when adding a column?
Browse by topic:SQL

Handwritten Step-by-Step Solution
Get this as a handwritten image on WhatsApp — like a tutor wrote it for you.
Try on WhatsApp