-1

This error keeps showing even though the parent table has been created,

"#1054 - Unknown column 'B722' in 'field list'".

I followed the following code from the student guide. Please help.

Table:

DROP TABLE IF EXISTS `Aircraft_Type`;

CREATE TABLE IF NOT EXISTS `Aircraft_Type`(
    `AT_ID` varchar(15) NOT NULL,
    `AT_Name` varchar(50) NOT NULL,
    CONSTRAINT AircraftType_pk_ATID PRIMARY KEY (`AT_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Query:

INSERT INTO `Aircraft_Type` (`AT_ID`, `AT_Name`)
VALUES (B722,Boeing 727-200),(B732,Boeing 737-300);
GSerg
  • 76,472
  • 17
  • 159
  • 346
Riri
  • 1
  • 1

2 Answers2

1

You need single quote for value and backtics for columns name

INSERT INTO `Aircraft_Type` (`AT_ID`, `AT_Name`)
VALUES ('722','Boeing 727-200'),('732','Boeing 737-300');
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
0

You do not use backticks in MySQL except for table and column names.

You need VALUES ('722', 'Boeing 727-200'),('732','Boeing 737-300')

Pro tip: SQL code is easier to type, easier to read, and more portable if you avoid using backticks in queries unless your table or column name is a reserved word. For example, your query could be:

INSERT INTO Aircraft_Type (AT_ID, AT_Name)
   VALUES ('722','Boeing 727-200'),('732','Boeing 737-300');

But a different query with reserved-word tables and columns might have to be:

INSERT INTO `group` (`order`, `where`)
   VALUES ('722','Boeing 727-200'),('732','Boeing 737-300');

to show those items are actually names, not parts of SQL statements.

Pro tip: Avoid using reserved words for column or table names.

O. Jones
  • 103,626
  • 17
  • 118
  • 172