I'm new to this website so let me know if I'm doing something wrong.
I'm trying to make a system where every time a value is inserted into the table, it's given an ID. So the first one would be 21, next one 22, 23, and so on.
I'm fairly new at SQL so I threw this together hoping it'd work, and I figured I'd come here and ask for some help.
This is what I thought up:
CREATE TABLE _increment
(
ID int NOT NULL AUTO_INCREMENT,
user_id varchar(255) NOT NULL,
group_id varchar(255),
alias varchar(255),
notes varchar(255),
value varchar(255),
hash varchar(255),
function_id varchar(255),
PRIMARY KEY (ID)
)
INSERT INTO _increment
(`user_id`, `group_id`, `alias`, `hash`, `function_id`, `value`, `disabled`)
VALUES ('262', NULL, NULL, 'john', 'wewbsite.ca/', NULL, '0');
CREATE TABLE _increment
The main points were some syntax errors, namely a missing semicolon at the end of the CREATE TABLE
statement
CREATE TABLE _increment
(
ID int NOT NULL AUTO_INCREMENT,
user_id varchar(255) NOT NULL,
group_id varchar(255),
alias varchar(255),
notes varchar(255),
value varchar(255),
hash varchar(255),
function_id varchar(255),
PRIMARY KEY (ID)
); -- this one was missing
and a wrong column name in the INSERT INTO
statement
INSERT INTO _increment
(`user_id`, `group_id`, `alias`, `hash`, `function_id`, `value`, `notes`) -- not `disabled`
VALUES ('262', NULL, NULL, 'john', 'wewbsite.ca/', NULL, '0');
If one hasn't got a mysql server ready to experiment and learn then I can recommend sqlfiddle to test such statements.