12

I am trying to insert an entry into a table, using Java, and it returns me an error "Unknown column XX in 'field list'".

For example: I have created a table using this line:

CREATE  TABLE `dbcs`.`born in` (`person` VARCHAR(100) ,`year` INT ,`prob` FLOAT);

the table was created successfully.

when I try to insert something to the table, it shows me the error. for example, the command:

INSERT INTO `dbcs`.`born in` VALUES (`Alanis Morissette`,1974,1.0)

will generate the error:

Unknown column 'Alanis Morissette' in 'field list'

John Conde
  • 217,595
  • 99
  • 455
  • 496
Pasha
  • 175
  • 1
  • 1
  • 9
  • Delimit String values with quotes i.e. INSERT INTO dbcs.born in VALUES ('Alanis Morissette',1974,1.0) – myqyl4 Feb 11 '13 at 17:29

2 Answers2

22

Strings must be wrapped in quotes. You're using ticks which are not correct.

INSERT INTO `dbcs`.`born in` VALUES ('Alanis Morissette',1974,1.0)
logi-kal
  • 7,107
  • 6
  • 31
  • 43
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • I think you need some backticks around `born in`. Also, I would emphasize that backticks should be used for system names. – Kermit Feb 11 '13 at 17:29
  • @Kermit I would have also added don't use spaces in names and avoid using a reserved keyword as a table/column name unless you really want to annoy somebody :-) – Endophage Dec 01 '14 at 16:49
  • @Endophage In the table name, yes. – Kermit Dec 01 '14 at 21:34
2

use

INSERT INTO dbcs.born in VALUES ('Alanis Morissette',1974,1.0)
Akash
  • 4,956
  • 11
  • 42
  • 70