MySQL Forums
Forum List  »  Newbie

Re: INSERT INTO NULLABLE FIELDS THROWING ERRORS WITH NULL VALUES
Posted by: Shecky Van Sheck
Date: September 16, 2014 11:36AM

Thanks Peter, I hope you don't mind a follow-up question or six …

echo $query (w/single-quoted values in the query):

	INSERT INTO Invoices SET INVOICE_NUMBER = '1004',
		INVOICE_DATE = '2014-09-16',
		PROJECT_NUMBER = '1003',
		CLIENT = 'Client 03 whatever',
		PROJECT_DESCRIPTION = 'whatever',
		TOTAL_HOURS = '30',
		SUBTOTAL = '0.00',
		TAX = '',
		INVOICE_TOTAL = '',
		DATE_SENT = '',
		DATE_RECEIVED = '2014-09-16',
		NOTES = '4'
		ON DUPLICATE KEY UPDATE <snip />


... and w/out single-quoted values:

INSERT failed: (1064) 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 '03, PROJECT_DESCRIPTION = whatever, TOTAL_HOURS = 30, SUBTOTAL ' at line 5

	INSERT INTO Invoices SET
		INVOICE_NUMBER = 1004,
		INVOICE_DATE = 2014-09-16,
		PROJECT_NUMBER = 1003,
		CLIENT = Client 03 whatever,
		PROJECT_DESCRIPTION = whatever,
		TOTAL_HOURS = 30,
		SUBTOTAL = 0.00,
		TAX = ,
		INVOICE_TOTAL = ,
		DATE_SENT = ,
		DATE_RECEIVED = 2014-09-16,
		NOTES = 4 
		ON DUPLICATE KEY UPDATE <snip />

Man, I don't know how to interpret this, totally baffling, this used to work. Have I done something stupid to the fields or the table? Is the engine, charset or collation not impacting this? Do I even understand correctly (pls see OP) that these fields should be able to insert nothing?

Thank you,

svs

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.