PDA

View Full Version : Timestamp


ooiyh
09-16-2009, 08:12 AM
I got an error when I try to insert this sql statment

CREATE TABLE FBMESSAGE(
Fbuser_id_sender INT NOT NULL ,
Fbuser_id_receiver INT NOT NULL ,
Msg_id INT NOT NULL ,
Mtext VARCHAR( 20 ) ,
Mtimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( Fbuser_id_sender, Fbuser_id_receiver, Msg_id ) ,
FOREIGN KEY ( Fbuser_id_sender ) REFERENCES FACEBOOKUSER( Id ) ,
FOREIGN KEY ( Fbuser_id_receiver ) REFERENCES FACEBOOKUSER( Id ) ,
);

MySQL said: Documentation
#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 ')' at line 11

MSQL indicates the error is at the TIMESTAMP statment.
Please help

SKDevelopment
09-16-2009, 02:23 PM
Remove the comma after the last FOREIGN KEY:

FOREIGN KEY ( Fbuser_id_receiver ) REFERENCES FACEBOOKUSER( Id )

The result would be:

CREATE TABLE FBMESSAGE(
Fbuser_id_sender INT NOT NULL ,
Fbuser_id_receiver INT NOT NULL ,
Msg_id INT NOT NULL ,
Mtext VARCHAR( 20 ) ,
Mtimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( Fbuser_id_sender, Fbuser_id_receiver, Msg_id ) ,
FOREIGN KEY ( Fbuser_id_sender ) REFERENCES FACEBOOKUSER( Id ) ,
FOREIGN KEY ( Fbuser_id_receiver ) REFERENCES FACEBOOKUSER( Id )
);