'SQL bad attribute (column) names

I've created table in MySQL database with the query:

CREATE TABLE IF NOT EXISTS `CREW` (
`ID` INT NOT NULL,
`CALL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`ID`));

And it did work perfectly, but when I tried to:

INSERT INTO CREW (ID, CALL) VALUES (0, 'None');

I've got ERROR 1064. What are the other bad names for attributes that we should avoid?



Solution 1:[1]

You should do it like you did it in your create statement. Sourround the attribute names and the table names with backticks:

INSERT INTO `CREW` (`ID`, `CALL`) VALUES (0, 'None');

If you do it always like this, you don't need to avoid any names.

Solution 2:[2]

One of the column name is 'CALL' in your CREW table. The CALL statement used to invoke a stored procedure. So when you are executing

INSERT INTO CREW (ID, CALL) VALUES (0, 'None');

Mysql understand that you are some how trying to execute a stored procedure. So you need to Surround the attribute names with back-ticks

INSERT INTO CREW ('ID', 'CALL') VALUES (0, 'None');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 steven
Solution 2 Bacteria