开发者

What's wrong with this SQL code syntax? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question

I'm trying to implement this code into my script but I get a syntax error

INSERT INTO prospectstbl ( 'customerNumber', 'namePerson1', 'LnamePerson1', 'street', 'city', 'state', 'zip', 'homePhone', 'cellPhone', 'clientSince', 'clientLevel', 'closingDate', 'lastPaymentDate', 'currentBalance', 'repurchaseDate', 'repurchaseAmount', 'delinquentBalance', ) VALUES ('20713254', 'Sonia', 'Amaya', '338 Railroad Ave', 'Ctr Moriches', 'NY', '11934', '6318788386', '6318137972', '10/24/2002', '1', '7/26/2011', '8/11/2011', '$792.15', '', '$0.00', '$0.00')

and the error I get:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''customerNumber', 'namePerson1', 'LnamePerson1', '开发者_开发技巧street', ' at line 2

Any help would be greatly appreciated.


remove the '' at the column names and the , at the last column:

INSERT INTO prospectstbl ( customerNumber, namePerson1, LnamePerson1, street, city, 
state, zip, homePhone, cellPhone, clientSince, clientLevel, closingDate, 
lastPaymentDate, currentBalance, repurchaseDate, repurchaseAmount, delinquentBalance ) 
VALUES ('20713254', 'Sonia', 'Amaya', '338 Railroad Ave', 'Ctr Moriches', 'NY', '11934', '6318788386', '6318137972', '10/24/2002', '1', '7/26/2011', '8/11/2011', '$792.15', '', '$0.00', '$0.00') 


There is a comma , after 'delinquentBalance'


use

`

instead of

'

And remove , after , delinquentBalance

or you can remove list of your columns

INSERT INTO prospectstbl VALUES ('20713254', 'Sonia', 'Amaya', '338 Railroad Ave', 'Ctr Moriches', 'NY', '11934', '6318788386', '6318137972', '10/24/2002', '1', '7/26/2011', '8/11/2011', '$792.15', '', '$0.00', '$0.00')


IIRC, single quotes (') are generally used for quoting literal values (strings and such) and indicating that certain tokens are NOT fieldnames. Graves (`) are used to indicate fields.

Try quoting your column names with graves (`) instead.

Also, as others have said, you have an extra comma at the end of your column name list. Remove this as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜