Lai Mom Cin Lai Mom Cin -4 years ago 70
MySQL Question

Unable to execute command: MySQL

create table
payrollmanagementsystem
.DEDUCTION
(
CODE VARCHAR(50) not null primary key,
NAME VARCHAR(50),
SALARYPERDAY DOUBLE PRECISION,
LEAVE INT,
KWSP DOUBLE PRECISION,
TOTALDEDUCTION DOUBLE PRECISION
)


I had face the problem with unable to execute command as error below:

Unable to execute command:
create table
payrollmanagementsystem
.DEDUCTION
(
CODE VARCHAR(50) not null primary key,
NAME VARCHAR(50),
SALARYPERDAY DOUBLE PRECISION,
LEAVE INT,
KWSP DOUBLE PRECISION,
TOTALDEDUCTION DOUBLE PRECISION
)
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 'LEAVE INT,
KWSP DOUBLE PRECISION,
TOTALDEDUCTION DOUBLE PRECISION
)' at line 6

Answer Source

As others pointed out, LEAVE is a keyword. To solve your problem, use backticks:

`LEAVE` INT,

Be aware that CODE is a keyword as well, though in this case it won't cause a problem. It's still good practice to escape your column names.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download