Search code examples
mysqlcreate-table

MySQL Syntax Error in Create Table Statement


I'm not that great at SQL statements, sorry, I have a statement:

CREATE TABLE app (  
    id INT NOT NULL AUTO_INCREMENT,  
    attachments LONGTEXT,  
    cc TEXT,  
    cc_full TEXT,  
    date TEXT NOT NULL,  
    from TEXT,  
    from_full TEXT NOT NULL,  
    headers TEXT NOT NULL,  
    html_body LONGTEXT,  
    mailbox_hash TEXT NOT NULL,  
    message_id TEXT NOT NULL,  
    reply_to TEXT,  
    subject TEXT NOT NULL,  
    tag TEXT,  
    text_body LONGTEXT,  
    to TEXT,  
    to_full TEXT NOT NULL, 
    PRIMARY KEY(id)
)

Unfortunately, I receive this error :

error (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 'from TEXT, from_full TEXT NOT NULL, headers TEXT NOT NULL, html_body LONGTEXT, m' at line 1

I thought it might be the 'from' being a reserved words problem so I wrapped all my column names in quotes too, but still no joy!

Please help!


Solution

  • FROM is a reserved MySQL keyword. Change your fieldname to something else.
    Same thing with your date and tofields.