简体   繁体   English

将数据插入MySQL表

[英]Inserting data into a MySQL table

So I have a question about inserting data into a table, here's the question: 所以我有一个关于将数据插入表中的问题,这是一个问题:

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 

Here is the code that I have come up with: 这是我想出的代码:

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

I'm getting an error saying that it's not right, what am I not doing right? 我收到一个错误消息,说这是不对的,我在做什么不对? Thanks 谢谢

The balance column is a decimal , but you're trying to insert a string value: balance列是一个decimal ,但是您尝试插入一个字符串值:

'17.56'

Instead, insert a numeric value: 而是插入一个数值:

17.56

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM