I have the following table in MySQL (version 5):
id int(10) UNSIGNED No auto_increment
year varchar(4) latin1_swedish_ci No
title varchar(250) latin1_swedish_ci Yes NULL
body text latin1_swedish_ci Yes NULL
And I want the db to auto add the current year on insert, I've tried the following SQL statement:
ALTER TABLE `tips` CHANGE `year` `year` VARCHAR( 4 ) NOT NULL DEFAULT year(now())
But it gives the following error:
1067 - Invalid default value for 'year'
What can I do to get this functionality? Thanks in advance!
@gabriel1863: Thanks for the reply, but im still getting the same error. Even when I use backticks on the year field.
Thank you all for the help!