We read your photo as:

How to fix SQL syntax error when inserting data with column names containing spaces in MySQL?

Computer Science

ScanSolve AI Answer

Answer

The error ERROR 1064 (42000): You have an error in your SQL syntax for the INSERT INTO Salary statement is due to the column name Basic Salary containing a space. In MySQL, column names with spaces must be enclosed in backticks (`).

Step-by-step solution

2 steps

Here is the corrected command for inserting into the Salary table:

  1. Ensure you have successfully inserted the employee into the Employee table first (as per the previous step).

  2. Insert the salary details for the new employee into the Salary table, enclosing Basic Salary in backticks.

    INSERT INTO Salary (SalaryID, EmpID, ‘Basic Salary‘, Bonus)VALUES (11, 11, 18000, NULL);\text{INSERT INTO Salary (SalaryID, EmpID, `Basic Salary`, Bonus)} \\ \text{VALUES (11, 11, 18000, NULL);}

    Execute this command after the Employee insertion.

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
Handwritten step-by-step solution preview

Handwritten Step-by-Step Solution

Get this as a handwritten image on WhatsApp — like a tutor wrote it for you.

Try on WhatsApp