table creation issue

They have: 461 posts

Joined: Jul 2003

not sure why but it keeps telling me i have an error at "when...."

i can't find anything that tells me when is a reserved word so i don't really know what's the issue here. any help would be appreciated.

CREATE TABLE apphist(
       appindex int unsigned NOT NULL auto_increment PRIMARY KEY,
       approver varchar(15) NOT NULL,
       member varchar(15) NOT NULL,
       item tinyint(1) NOT NULL,
       reason tinytext,
       ok tinyint(1) NOT NULL,
       when datetime default '0000-00-00 00:00:00' NOT NULL,
       KEY approver (approver),
       KEY member (member),
       KEY item (item),
       KEY ok (ok),
       KEY when (when)
) TYPE=MyISAM;
'note: this table is used to log the approval/rejection of things on the site... incase someone witht he power to approve/reject decides to abuse it. if someone feels it's being abused the ways built in to track down the pattern are by approver, member, item, and date. if it's been approved (ok) is there incase an admin wants to review recent actions of just approvals or rejections.

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Busy's picture

He has: 6,151 posts

Joined: May 2001

I think when and ok are reserved words (could be wrong)

try adding is_ok and did_when or something and see if the errors go away

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

http://www.mysql.com/doc/en/Reserved_words.html

"WHEN" is on the list. Though, I don't remember ever using it.

They have: 461 posts

Joined: Jul 2003

the books i have have mentions of reseved words scattered around. it's likely i missed it while looking for them, but i like that page MUCH better. already bookmarked and filed it for the future =o)

i didn't think of the possibility that i might havemissed one since they're scattered. that's why i came here first. i thought itwas something inthe declaration that i was overlooking and was too minor for me to see since i'm "too close to the code"

thanx again for the reserved word page =o)

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 30 posts

Joined: Aug 2003

this will work.

CREATE TABLE apphist(
appindex int unsigned NOT NULL auto_increment PRIMARY KEY,
approver varchar(15) NOT NULL,
member varchar(15) NOT NULL,
item tinyint(1) NOT NULL,
reason tinytext,
ok tinyint(1) NOT NULL,
`when` datetime default '0000-00-00 00:00:00' NOT NULL,
KEY approver (approver),
KEY member (member),
KEY item (item),
KEY ok (ok),
KEY `when` (`when`)
) TYPE=MyISAM;

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.