将数据插入MySQL表

时间:2016-04-08 19:27:11

标签: mysql sql insert

所以我有一个关于将数据插入表格的问题,这里的问题是:

Assume a database table: customers

Assume these columns

name     varchar(10)

streetAddress     varchar)15)

stateAbbreviation     varchar(2)

balance     decimal(6,2)

Write the SQL that will insert a record to the customers table with these values:

name:     Jimmy

streetAddress:     10 Main St.

stateAbbreviation:     KS

balance:     17.56 

以下是我提出的代码:

insert into customers (name,streetAddress,stateAbbreviation,balance) values ('Jimmy','10 Main St.','KS','17.56');

我收到一条错误消息,说它不对,我做得对不对?感谢

1 个答案:

答案 0 :(得分:0)

balance列是decimal,但您尝试插入字符串值:

'17.56'

而是插入一个数值:

17.56