Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql giving A comma or a closing bracket was expected (near "(" at position 109)

Tags:

php

mysql

I just updated mysql and I don't see the missing bracket

CREATE TABLE payments 
(   id int(11) NOT NULL, 
    amount int(11) NOT NULL, 
    alloted datetime NOT NULL, 
    dateadded datetime NOT NULL, 
    modified datetime NOT NULL, 
    userid int(11) NOT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


INSERT INTO payments (`amount`,`alotted`, `dateadded`, `modified`, `userid`)
VALUES ( 100, DATE_ADD( NOW(), INTERVAL 6 MONTHS),NOW(),NOW(),139107 )
like image 407
user3308713 Avatar asked Sep 12 '16 06:09

user3308713


1 Answers

You had a typo near alloted. It is MONTH not MONTHS.

And the id column had no default value. So I made an AUTO_INCREMENT

And on the INSERT, those are called back-ticks folks. They are fine.

DROP TABLE payments;
CREATE TABLE payments 
(   id int AUTO_INCREMENT PRIMARY KEY, 
    amount int NOT NULL, 
    alloted datetime NOT NULL, 
    dateadded datetime NOT NULL, 
    modified datetime NOT NULL, 
    userid int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO payments (`amount`,`alloted`, `dateadded`, `modified`, `userid`)
VALUES ( 100, DATE_ADD( NOW(), INTERVAL 6 MONTH),NOW(),NOW(),139107 )
like image 51
Drew Avatar answered Sep 17 '22 16:09

Drew